使用geopandas将shp导入postgresql数据库出错

def shp2pgsql(file, engine):
file_name = os.path.split(file)[1]
tbl_name = file_name.split('.')[0] # 表名
map_data = gpd.GeoDataFrame.from_file(file)
spatial_ref = map_data.crs.srs.split(':')[-1] # 读取shp的空间参考
map_data['geometry'] = map_data['geometry'].apply(
lambda x: WKTElement(x.wkt, spatial_ref))
map_data.to_sql(
name=tbl_name,
con=engine.connect(),
if_exists='replace',
chunksize=1000,
dtype={'geometry': Geometry(
geometry_type='GEOMETRY', srid=spatial_ref)},
method='multi',
schema='public'
)
错误:
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateTable) 错误: 关系 "idx_tbl_name_geometry" 已经存在
[SQL: CREATE INDEX idx_tbl_name_geometry ON public.tbl_name USING gist (geometry)]
shp文件就是从阿里geo上面下载的json文件转成的 python3.8的环境 一直报这个错误, 有没有遇到过的 解决了的