UnicodeDecodeError with pandas.read_sql

前端 未结 2 445
孤街浪徒
孤街浪徒 2021-01-05 10:07
UnicodeDecodeError: \'charmap\' codec can\'t decode byte 0x90 in position 8: character maps to 

Am seeing teh above error in a sim

相关标签:
2条回答
  • 2021-01-05 10:48

    Python3.7:

    con = sqlite3.connect(path_to_db)
    encoding = "latin1"
    con.text_factory = lambda x: str(x, encoding)
    # do not preserve non-printable
    # con.text_factory = lambda x: str(x, "ascii", errors="ignore")
    data = pd.read_sql_query(QUERY, con)
    

    Pydocs on text_factory

    0 讨论(0)
  • 2021-01-05 10:56

    the proper encoding for your database is iso-8859-1 according to oracle docs so When you connect() to your database, pass the charset='iso-8859-1' or encoding='iso-8859-1' try both.

    0 讨论(0)
提交回复
热议问题