From 9d75d420178eb3e6031c0e1972bb73b35f09c0d2 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Tue, 2 Apr 2024 12:59:26 -0500 Subject: [PATCH] bug fix: append mode/replace or truncate upon insert --- transport/sql/common.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/transport/sql/common.py b/transport/sql/common.py index 89dcefb..4c9d4a7 100644 --- a/transport/sql/common.py +++ b/transport/sql/common.py @@ -118,8 +118,12 @@ class BaseWriter (SQLBase): # _table = _args['table'] if 'table' in _args else self._table _mode = {'chunksize':2000000,'if_exists':'append','index':False} - if 'schema' in _args : - _mode['schema'] = _args['schema'] - if 'if_exists' in _args : - _mode['if_exists'] = _args['if_exists'] - _df.to_sql(_table,self._engine,**_args,index=False) \ No newline at end of file + for key in ['if_exists','index','chunksize'] : + if key in _args : + _mode[key] = _args[key] + # if 'schema' in _args : + # _mode['schema'] = _args['schema'] + # if 'if_exists' in _args : + # _mode['if_exists'] = _args['if_exists'] + + _df.to_sql(_table,self._engine,**_mode) \ No newline at end of file