diff --git a/setup.py b/setup.py index 9e1ae057..b98793ed 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ # version should use the format 'x.x.x' (instead of 'vx.x.x') setup( name='vertica-python', - version='0.4.5', + version='0.4.6', description='A native Python client for the Vertica database.', author='Justin Berka, Alex Kim, Kenneth Tran', author_email='justin.berka@gmail.com, alex.kim@uber.com, tran@uber.com', diff --git a/vertica_python/__init__.py b/vertica_python/__init__.py index d55bf661..ad2cd070 100644 --- a/vertica_python/__init__.py +++ b/vertica_python/__init__.py @@ -6,7 +6,7 @@ # Main module for this library. # The version number of this library. -version_info = (0, 4, 5) +version_info = (0, 4, 6) __version__ = '.'.join(map(str, version_info)) diff --git a/vertica_python/tests/basic_tests.py b/vertica_python/tests/basic_tests.py index bd81c148..a5707f40 100644 --- a/vertica_python/tests/basic_tests.py +++ b/vertica_python/tests/basic_tests.py @@ -229,3 +229,26 @@ def test_query_errors(self): assert 1 == len(res) assert 1 == res[0][0] assert 'aa' == res[0][1] + + def test_cursor_close_and_reuse(self): + + conn = vertica_python.connect(conn_info) + cur = conn.cursor() + init_table(cur) + + # insert data + cur.execute(""" INSERT INTO vertica_python_unit_test (a, b) VALUES (2, 'bb'); commit; """) + #conn.commit() + + # query + cur.execute("SELECT a, b from vertica_python_unit_test WHERE a = 2") + res = cur.fetchall() + assert 1 == len(res) + + # close and reopen cursor + cur.close() + cur = conn.cursor() + + cur.execute("SELECT a, b from vertica_python_unit_test") + res = cur.fetchall() + assert 1 == len(res) diff --git a/vertica_python/vertica/connection.py b/vertica_python/vertica/connection.py index 1cb76fa4..06f8f138 100644 --- a/vertica_python/vertica/connection.py +++ b/vertica_python/vertica/connection.py @@ -77,11 +77,13 @@ def cursor(self, cursor_type=None): if self.closed(): raise errors.ConnectionError('Connection is closed') + if self._cursor.closed(): + self._cursor._closed = False + # let user change type if they want? self._cursor.cursor_type = cursor_type return self._cursor - # # Internal # diff --git a/vertica_python/vertica/cursor.py b/vertica_python/vertica/cursor.py index e2dbcc1d..f08b6b56 100644 --- a/vertica_python/vertica/cursor.py +++ b/vertica_python/vertica/cursor.py @@ -136,7 +136,6 @@ def setoutputsize(self, size, column=None): # # Non dbApi methods # - # todo: input stream def flush_to_query_ready(self): # if the last message isnt empty or ReadyForQuery, read all remaining messages if(self._message is None