From 5580212d045b825999ebac3a6b1b3a25d02588f3 Mon Sep 17 00:00:00 2001 From: Steven Li Date: Mon, 8 Jun 2020 17:37:31 -0700 Subject: [PATCH] Added errno to Python client, plus minor tweaks --- src/connector/python/linux/python2/taos/cursor.py | 2 +- src/connector/python/linux/python3/taos/cursor.py | 2 +- src/connector/python/windows/python2/taos/cursor.py | 2 +- src/connector/python/windows/python3/taos/cursor.py | 2 +- tests/pytest/crash_gen.py | 10 ++++++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/connector/python/linux/python2/taos/cursor.py b/src/connector/python/linux/python2/taos/cursor.py index f7c840442e..8c268d8afb 100644 --- a/src/connector/python/linux/python2/taos/cursor.py +++ b/src/connector/python/linux/python2/taos/cursor.py @@ -137,7 +137,7 @@ class TDengineCursor(object): else: raise ProgrammingError( CTaosInterface.errStr( - self._result )) + self._result ), errno) def executemany(self, operation, seq_of_parameters): """Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters. diff --git a/src/connector/python/linux/python3/taos/cursor.py b/src/connector/python/linux/python3/taos/cursor.py index 5db5365eb3..06d6a19462 100644 --- a/src/connector/python/linux/python3/taos/cursor.py +++ b/src/connector/python/linux/python3/taos/cursor.py @@ -139,7 +139,7 @@ class TDengineCursor(object): else: raise ProgrammingError( CTaosInterface.errStr( - self._result )) + self._result), errno) def executemany(self, operation, seq_of_parameters): """Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters. diff --git a/src/connector/python/windows/python2/taos/cursor.py b/src/connector/python/windows/python2/taos/cursor.py index 1da726638a..7eee3bfc8f 100644 --- a/src/connector/python/windows/python2/taos/cursor.py +++ b/src/connector/python/windows/python2/taos/cursor.py @@ -117,7 +117,7 @@ class TDengineCursor(object): self._fields = CTaosInterface.useResult(self._result) return self._handle_result() else: - raise ProgrammingError(CTaosInterface.errStr(self._result)) + raise ProgrammingError(CTaosInterface.errStr(self._result), errno) def executemany(self, operation, seq_of_parameters): """Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters. diff --git a/src/connector/python/windows/python3/taos/cursor.py b/src/connector/python/windows/python3/taos/cursor.py index 2dcd0aaccb..5f5aa4e1d7 100644 --- a/src/connector/python/windows/python3/taos/cursor.py +++ b/src/connector/python/windows/python3/taos/cursor.py @@ -117,7 +117,7 @@ class TDengineCursor(object): self._fields = CTaosInterface.useResult(self._result ) return self._handle_result() else: - raise ProgrammingError(CTaosInterface.errStr(self._result )) + raise ProgrammingError(CTaosInterface.errStr(self._result ), errno) def executemany(self, operation, seq_of_parameters): """Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters. diff --git a/tests/pytest/crash_gen.py b/tests/pytest/crash_gen.py index dfd2034f7e..c88683aa09 100755 --- a/tests/pytest/crash_gen.py +++ b/tests/pytest/crash_gen.py @@ -730,13 +730,15 @@ class DbState(): # when we re-run the test in 3 minutes (180 seconds), basically we should expand time duration # by a factor of 500. # TODO: what if it goes beyond 10 years into the future + # TODO: fix the error as result of above: "tsdb timestamp is out of range" def setupLastTick(self): - t1 = datetime.datetime(2020, 5, 30) + t1 = datetime.datetime(2020, 6, 1) t2 = datetime.datetime.now() - elSec = t2.timestamp() - t1.timestamp() + elSec = int(t2.timestamp() - t1.timestamp()) # maybe a very large number, takes 69 years to exceed Python int range + elSec2 = ( elSec % (8 * 12 * 30 * 24 * 60 * 60 / 500 ) ) * 500 # a number representing seconds within 10 years # print("elSec = {}".format(elSec)) t3 = datetime.datetime(2012, 1, 1) # default "keep" is 10 years - t4 = datetime.datetime.fromtimestamp( t3.timestamp() + elSec * 500) # see explanation above + t4 = datetime.datetime.fromtimestamp( t3.timestamp() + elSec2) # see explanation above logger.info("Setting up TICKS to start from: {}".format(t4)) return t4 @@ -963,7 +965,7 @@ class Task(): try: self._executeInternal(te, wt) # TODO: no return value? except taos.error.ProgrammingError as err: - self.logDebug("[=] Taos library exception: errno={}, msg: {}".format(err.errno, err)) + self.logDebug("[=] Taos library exception: errno={:X}, msg: {}".format(err.errno, err)) self._err = err except: self.logDebug("[=] Unexpected exception") -- GitLab