[Python-modules-commits] [python-vertica] 01/03: Import python-vertica_0.6.7.orig.tar.gz

Jean Baptiste Favre jbfavre-guest at moszumanska.debian.org
Sat Oct 1 17:35:32 UTC 2016


This is an automated email from the git hooks/post-receive script.

jbfavre-guest pushed a commit to branch master
in repository python-vertica.

commit c01d508d51eb4ea960d4b2fb910c8dffb69937d7
Author: Jean Baptiste Favre <github at jbfavre.org>
Date:   Sat Oct 1 17:33:41 2016 +0200

    Import python-vertica_0.6.7.orig.tar.gz
---
 README.md                             |  4 ++--
 setup.py                              |  2 +-
 vertica_python/__init__.py            |  2 +-
 vertica_python/tests/unicode_tests.py | 24 ++++++++++++++++++++++++
 vertica_python/vertica/connection.py  |  1 +
 vertica_python/vertica/cursor.py      |  8 ++++----
 6 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 5ceb51b..dff7bf1 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
 
 [![PyPI version](https://badge.fury.io/py/vertica-python.png)](http://badge.fury.io/py/vertica-python)
 
-0.6.x adds python3 support (namedparams support is currently broken in python3, see issue 112)
+0.6.x adds python3 support (unicode namedparams support is currently broken in python3, see issue 112)
 
 0.5.x changes the connection method to accept kwargs instead of a dict to be more dbapi compliant.
       copy methods improved and consolidated in 0.5.1
@@ -71,7 +71,7 @@ conn_info = {'host': '127.0.0.1',
              # 10 minutes timeout on queries
              'read_timeout': 600,
              # default throw error on invalid UTF-8 results
-             'unicode_error': 'strict'
+             'unicode_error': 'strict',
              # SSL is disabled by default
              'ssl': False}
 
diff --git a/setup.py b/setup.py
index ebc4a48..9e22074 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ opts = ReqOpts(None, 'git')
 # version should use the format 'x.x.x' (instead of 'vx.x.x')
 setup(
     name='vertica-python',
-    version='0.6.6',
+    version='0.6.7',
     description='A native Python client for the Vertica database.',
     author='Justin Berka, Alex Kim',
     author_email='justin.berka at gmail.com, alex.kim at uber.com',
diff --git a/vertica_python/__init__.py b/vertica_python/__init__.py
index cd486e6..e01c064 100644
--- a/vertica_python/__init__.py
+++ b/vertica_python/__init__.py
@@ -6,7 +6,7 @@ from vertica_python.vertica.connection import Connection
 # Main module for this library.
 
 # The version number of this library.
-version_info = (0, 6, 6)
+version_info = (0, 6, 7)
 
 __version__ = '.'.join(map(str, version_info))
 
diff --git a/vertica_python/tests/unicode_tests.py b/vertica_python/tests/unicode_tests.py
index adf1314..2cfaebb 100644
--- a/vertica_python/tests/unicode_tests.py
+++ b/vertica_python/tests/unicode_tests.py
@@ -26,3 +26,27 @@ class UnicodeTestCase(VerticaTestCase):
             res = cur.fetchone()
 
             assert res[0] == value
+
+    def test_string_query(self):
+        value = u'test'
+        query = u"SELECT '{}'".format(value)
+
+        with connect(**conn_info) as conn:
+            cur = conn.cursor()
+            cur.execute(query)
+            res = cur.fetchone()
+
+            assert res[0] == value
+
+    # this test is broken on python3: see issue #112
+    def test_string_named_parameter_binding(self):
+        key = u'test'
+        value = u'value'
+        query = u"SELECT :{}".format(key)
+
+        with connect(**conn_info) as conn:
+            cur = conn.cursor()
+            cur.execute(query, {key: value})
+            res = cur.fetchone()
+
+            assert res[0] == value
diff --git a/vertica_python/vertica/connection.py b/vertica_python/vertica/connection.py
index b4758e7..4084635 100644
--- a/vertica_python/vertica/connection.py
+++ b/vertica_python/vertica/connection.py
@@ -106,6 +106,7 @@ class Connection(object):
         host = self.options.get('host')
         port = self.options.get('port')
         raw_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        raw_socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
         raw_socket.connect((host, port))
 
         ssl_options = self.options.get('ssl')
diff --git a/vertica_python/vertica/cursor.py b/vertica_python/vertica/cursor.py
index cedc0b5..6d786d2 100644
--- a/vertica_python/vertica/cursor.py
+++ b/vertica_python/vertica/cursor.py
@@ -54,16 +54,16 @@ class Cursor(object):
 
         if parameters:
             # # optional requirement
+            import six
             from psycopg2.extensions import adapt
 
             if isinstance(parameters, dict):
                 for key in parameters:
                     param = parameters[key]
                     # Make sure adapt() behaves properly
-                    if isinstance(param, str):
-                        v = adapt(param.encode('utf8')).getquoted()
-                    else:
-                        v = adapt(param).getquoted()
+                    if six.PY2:
+                        param = param.encode('utf8')
+                    v = adapt(param).getquoted()
 
                     # Using a regex with word boundary to correctly handle params with similar names
                     # such as :s and :start

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-vertica.git



More information about the Python-modules-commits mailing list