【postgis】【geopandas】【UnicodeDecodeError】
代码如下:
conn = create_engine(f"postgresql://{user}:{password}@{host}:{port}/{database}")
sql = "SELECT * from train_way limit 10"
# sql = "select postgis_version()"
data = gpd.read_postgis(sql, conn, geom_col='geom')
报错 信息:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)
解决方法:
conn = create_engine(f"postgresql://{user}:{password}@{host}:{port}/{database}?client_encoding=utf8")
# conn = psycopg2.connect(host=host,port=port,user=user,password=password,database=database,client_encoding='utf-8')
sql = "SELECT * from train_way limit 10"
# sql = "select postgis_version()"
data = gpd.read_postgis(sql, conn, geom_col='geom')