UnicodeDecodeError with pandas.read_sql
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.
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