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

后端 未结 4 1832
清酒与你
清酒与你 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:33

    encoding parameter does not work correctly.

    So, as @doru said in this link, you should add ?charset=utf8mb4 at the end of the connection string. like this:

    connect_string = 'mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8mb4'.format(DB_USER, DB_PASS, DB_HOST, DB_PORT, DATABASE)
    

提交回复
热议问题