Commit bc619374 authored by ARCHER's avatar ARCHER 💬

check table exists before try to read column srid

parent b5c823e0
......@@ -126,3 +126,4 @@ dmypy.json
.project
.pydevproject
/.dbeaver-data-sources.xml
......@@ -81,9 +81,10 @@ def to_postgis(gdf,*args,**kwargs):
con1=session.connection().connect()
if 'if_exists' in kwargs and kwargs['if_exists'] == 'append':
if 'if_exists' in kwargs and kwargs['if_exists'] == 'append' and con1.dialect.has_table(con1, table):
# get actual column srid
column_srid=con1.execute('''SELECT Find_SRID('', '%s', '%s');''' % (table , gdf.geometry.name)).fetchone()[0]
if column_srid != srid:
raise ValueError("geopandas srid %s doesn't match postgis Find_SRID %s" % (srid , column_srid))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment