psycopg2链接postgreSQL时,查询数据提示:ascii编码错误

psycopg2链接postgreSQL时,查询数据提示
File "C:/Users/zhanglin/Desktop/db_apiauto-master/Conf/sql.py", line 23, in select_hosp_white
info = cursor.fetchall()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)

试了很多办法 都还是报这个问题
python 3.8

对于混合编码的数据库,可以用bytes设置一下。参考 https://www.psycopg.org/docs/usage.html, 页面里有示例代码参考一下:

import psycopg2.extensions
psycopg2.extensions.register_type(psycopg2.extensions.BYTES, conn)
psycopg2.extensions.register_type(psycopg2.extensions.BYTESARRAY, conn)
cur = conn.cursor()
cur.execute("select %s::text", (u"€",))
cur.fetchone()[0]
b'\xe2\x82\xac'