UnicodeDecodeError with pandas.read_sql

前端 未结 2 444
孤街浪徒
孤街浪徒 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

提交回复
热议问题