From 1d53387598606ef09105438ae57a4086f16fb194 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 21 May 2020 16:20:30 +0800 Subject: [PATCH] add log sql command to file for python2. --- src/connector/python/linux/python2/taos/cursor.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/connector/python/linux/python2/taos/cursor.py b/src/connector/python/linux/python2/taos/cursor.py index 3d738ab22d..7ea52aa5ad 100644 --- a/src/connector/python/linux/python2/taos/cursor.py +++ b/src/connector/python/linux/python2/taos/cursor.py @@ -34,6 +34,7 @@ class TDengineCursor(object): self._block_rows = -1 self._block_iter = 0 self._affected_rows = 0 + self._logfile = "" if connection is not None: self._connection = connection @@ -83,6 +84,9 @@ class TDengineCursor(object): """ pass + def log(self, logfile): + self._logfile = logfile + def close(self): """Close the cursor. """ @@ -113,6 +117,11 @@ class TDengineCursor(object): pass res = CTaosInterface.query(self._connection._conn, stmt) + + if (self._logfile): + with open(self._logfile, "a") as logfile: + logfile.write("%s;\n" % operation) + if res == 0: if CTaosInterface.fieldsCount(self._connection._conn) == 0: self._affected_rows += CTaosInterface.affectedRows( -- GitLab