Encoding error with sqlalchemy and postgresql

后端 未结 2 1641
暗喜
暗喜 2021-02-19 00:30

I\'m using pyramid for a web application with a postgres database, wtforms, sqlalchemy and jinja2 and I\'m having this error when the application try to get the issues types fro

2条回答
  •  别跟我提以往
    2021-02-19 01:15

    I use mysql and set the charset like this. It works for me.

    from sqlalchemy import create_engine
    from sqlalchemy.engine.url import URL
    
    db_url = {
        'database': 'db_name',
        'drivername': 'mysql',
        'username': 'username',
        'password': 'mypassword',
        'host': '127.0.0.1',
        'query': {'charset': 'utf8'},
    }
    
    engine = create_engine(URL(**db_url), encoding="utf8")
    

提交回复
热议问题