how to use `charset` and `encoding` in `create_engine` of SQLAlchemy (to create pandas dataframe)?

后端 未结 4 1827
清酒与你
清酒与你 2020-12-17 10:48

I am very confused with the way charset and encoding work in SQLAlchemy. I understand (and have read) the difference between charsets and encodings, and I h

4条回答
  •  独厮守ぢ
    2020-12-17 11:23

    I had the same problem. I just added ?charset=utf8mb4 at the end of the url.

    Here is mine:

    Before

    SQL_ENGINE = sqlalchemy.create_engine('mysql+pymysql://'+MySQL.USER+':'+MySQL.PASSWORD+'@'+MySQL.HOST+':'+str(MySQL.PORT)+'/'+MySQL.DB_NAME)
    

    After

    SQL_ENGINE = sqlalchemy.create_engine('mysql+pymysql://'+MySQL.USER+':'+MySQL.PASSWORD+'@'+MySQL.HOST+':'+str(MySQL.PORT)+'/'+MySQL.DB_NAME + "?charset=utf8mb4")
    

提交回复
热议问题