Pandas "read_sql" UnicodeDecodeError
Pandas "read_sql" UnicodeDecodeError
我使用 pandas
从 Vertica 数据库读取:
pd.read_sql(query, self._conn)
但是它失败了
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 1: invalid continuation byte
。
其他查询不会失败,因此问题 出在该查询的某些特定列中。
我需要所有数据 - 我该怎么办?我也可以在 Vertica 中进行更改,但我无法更改 table 值...
P.S。这就是我为 Vertica 创建连接的方式:
conn_info = url2vertica(url)
conn_info["read_timeout"] = 2400
conn_info["ssl"] = False
vrt = vertica_python.connect(**conn_info)
实际上,我想到了这个解决方案:在 sql-查询中使用 isUTF8()
。
同样在 here 中,在 UTF-8 编码问题 中,我们可以通过 'unicode_error': 'ignore'
.
忽略错误
我使用 pandas
从 Vertica 数据库读取:
pd.read_sql(query, self._conn)
但是它失败了
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 1: invalid continuation byte
。
其他查询不会失败,因此问题 出在该查询的某些特定列中。
我需要所有数据 - 我该怎么办?我也可以在 Vertica 中进行更改,但我无法更改 table 值...
P.S。这就是我为 Vertica 创建连接的方式:
conn_info = url2vertica(url)
conn_info["read_timeout"] = 2400
conn_info["ssl"] = False
vrt = vertica_python.connect(**conn_info)
实际上,我想到了这个解决方案:在 sql-查询中使用 isUTF8()
。
同样在 here 中,在 UTF-8 编码问题 中,我们可以通过 'unicode_error': 'ignore'
.