[CG] : add arg dtype to update_to_sql
This commit is contained in:
parent
0d2b1fa9c6
commit
879ae10150
@ -223,7 +223,7 @@ def update_ref(file, table, schema=None, update=False):
|
||||
update_ref_table(file, table, schema, update)
|
||||
|
||||
|
||||
def update_to_sql(df, con, table_name, schema_name, key_name, checkid=True):
|
||||
def update_to_sql(df, con, table_name, schema_name, key_name, checkid=True, dtype=None):
|
||||
from sys import exit
|
||||
|
||||
a = []
|
||||
@ -254,9 +254,9 @@ def update_to_sql(df, con, table_name, schema_name, key_name, checkid=True):
|
||||
if col in primary_key:
|
||||
b.append("t.{col}=f.{col}".format(col=col))
|
||||
else:
|
||||
dtype = type_cols[col]
|
||||
if hasattr(dtype,'enums') :
|
||||
dty = '.'.join([dtype.schema,dtype.name])
|
||||
dtyp = type_cols[col]
|
||||
if hasattr(dtyp,'enums') :
|
||||
dty = '.'.join([dtyp.schema,dtyp.name])
|
||||
a.append("{col}=t.{col}::{typ}".format(col=col,typ=dty))
|
||||
else:
|
||||
a.append("{col}=t.{col}".format(col=col))
|
||||
@ -266,7 +266,8 @@ def update_to_sql(df, con, table_name, schema_name, key_name, checkid=True):
|
||||
name = 'temp_table',
|
||||
con = con,
|
||||
schema = schema,
|
||||
if_exists = 'replace'
|
||||
if_exists = 'replace',
|
||||
dtype = dtype
|
||||
# geom_col = df.geometry.name
|
||||
)
|
||||
else:
|
||||
@ -276,7 +277,8 @@ def update_to_sql(df, con, table_name, schema_name, key_name, checkid=True):
|
||||
schema = schema,
|
||||
if_exists = 'replace',
|
||||
index = False,
|
||||
method = 'multi'
|
||||
method = 'multi',
|
||||
dtype = dtype
|
||||
)
|
||||
|
||||
update_stmt_1 = "UPDATE {sch}.{final_table} f".format(sch=schema,final_table=table)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user