Skip to content

to_sql throws latin-1 encoding error even though everything seems encoded in utf-8 #11047

@alybel

Description

@alybel

I want to upload a file from csv to mysql with the following commands

 df = pandas.read_csv('test.csv', encoding = 'utf-8')
engine = sqlalchemy.create(<Mysql-Connection-URI>, encoding = 'utf-8')
df.to_sql('testtable', con = engine)

mysql has utf-8 as global encoding. If I upload the file manually to the database it goes without problems.

using to_sql throws the following errror:
UnicodeEncodeError: 'latin-1' codec can't encode character '\u015e'etc...

Any ideas, where Latin-1 becomes part of the games and how this could be fixed? Thanks for any advice!

Metadata

Metadata

Assignees

No one assigned

    Labels

    IO SQLto_sql, read_sql, read_sql_query

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions