From 5bf2012c598f79dee694437ace73555174573d7a Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Sun, 10 Jan 2021 09:55:04 -0600 Subject: [PATCH] bug fix: batch update fixes --- setup.py | 2 +- transport/sql.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 2bbc294..e273072 100644 --- a/setup.py +++ b/setup.py @@ -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"]} diff --git a/transport/sql.py b/transport/sql.py index 47ca33a..6ffad70 100644 --- a/transport/sql.py +++ b/transport/sql.py @@ -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):