bug fix: batch update fixes

This commit is contained in:
Steve Nyemba 2021-01-10 09:55:04 -06:00
parent fa615aa931
commit 5bf2012c59
2 changed files with 8 additions and 4 deletions

View File

@ -8,7 +8,7 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
args = {
"name":"data-transport",
"version":"1.3.4",
"version":"1.3.6",
"author":"The Phi Technology LLC","author_email":"info@the-phi.com",
"license":"MIT",
"packages":["transport"]}

View File

@ -59,6 +59,7 @@ class SQLRW :
@TODO: Store procedure calls
"""
cursor = self.conn.cursor()
_out = None
try:
if "select" in _sql.lower() :
cursor.close()
@ -69,6 +70,7 @@ class SQLRW :
self.conn.commit()
finally:
self.conn.commit()
cursor.close()
def close(self):
try:
@ -142,13 +144,14 @@ class SQLWriter(SQLRW,Writer):
if self._cast == False :
values = ",".join(_row.values())
else:
values = "'"+"','".join([str(value) for value in _row.values()])+"'"
# values = "'"+"','".join([str(value) for value in _row.values()])+"'"
values = [",".join(["%(",name,")s"]) for name in _row.keys()]
# values = [ "".join(["'",str(_row[key]),"'"]) if np.nan(_row[key]).isnumeric() else str(_row[key]) for key in _row]
# print (values)
query = _sql.replace(":fields",",".join(fields)).replace(":values",values)
cursor.execute(query)
cursor.execute(query,_row.values())
pass
@ -160,10 +163,11 @@ class SQLWriter(SQLRW,Writer):
# for row in info :
# values = ["'".join(["",value,""]) if not str(value).isnumeric() else value for value in row.values()]
cursor.executemany(_sql,info)
self.conn.commit()
# self.conn.commit()
except Exception as e:
print (e)
finally:
self.conn.commit()
cursor.close()
pass
def close(self):