[Python-modules-commits] [python-vertica] 02/10: Import python-vertica_0.6.2.orig.tar.gz

Jean Baptiste Favre jbfavre-guest at moszumanska.debian.org
Mon May 23 19:39:09 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 8267539dc3f1bd9bac19348ddb9c8f6fac443af9
Author: Jean Baptiste Favre <debian at jbfavre.org>
Date:   Sun May 22 13:45:19 2016 +0200

    Import python-vertica_0.6.2.orig.tar.gz
---
 README.md                                          | 14 +++--
 requirements.txt                                   |  3 -
 requirements_test.txt                              |  1 -
 setup.py                                           |  9 ++-
 tox.ini                                            |  9 +++
 vertica_python/__init__.py                         |  4 +-
 vertica_python/datatypes.py                        |  2 +-
 vertica_python/errors.py                           | 38 ++++++++----
 vertica_python/tests/basic_tests.py                |  4 +-
 vertica_python/tests/date_tests.py                 |  2 +-
 vertica_python/tests/error_tests.py                | 62 +++++++++++++++++++
 vertica_python/tests/unicode_tests.py              | 16 ++++-
 vertica_python/vertica/column.py                   | 15 ++---
 vertica_python/vertica/connection.py               | 41 +++++++------
 vertica_python/vertica/cursor.py                   | 19 +++---
 vertica_python/vertica/messages/__init__.py        | 70 +++++++++++-----------
 .../messages/backend_messages/authentication.py    |  4 +-
 .../messages/backend_messages/backend_key_data.py  |  4 +-
 .../messages/backend_messages/bind_complete.py     |  4 +-
 .../messages/backend_messages/close_complete.py    |  4 +-
 .../messages/backend_messages/command_complete.py  | 12 ++--
 .../messages/backend_messages/copy_in_response.py  |  6 +-
 .../vertica/messages/backend_messages/data_row.py  |  7 ++-
 .../backend_messages/empty_query_response.py       |  4 +-
 .../messages/backend_messages/error_response.py    |  4 +-
 .../vertica/messages/backend_messages/no_data.py   |  4 +-
 .../messages/backend_messages/notice_response.py   | 30 +++++-----
 .../backend_messages/parameter_description.py      |  4 +-
 .../messages/backend_messages/parameter_status.py  |  6 +-
 .../messages/backend_messages/parse_complete.py    |  4 +-
 .../messages/backend_messages/portal_suspended.py  |  4 +-
 .../messages/backend_messages/ready_for_query.py   | 10 ++--
 .../messages/backend_messages/row_description.py   |  8 +--
 .../vertica/messages/backend_messages/unknown.py   |  2 +-
 .../vertica/messages/frontend_messages/bind.py     | 14 ++---
 .../messages/frontend_messages/cancel_request.py   |  2 +-
 .../vertica/messages/frontend_messages/close.py    |  4 +-
 .../messages/frontend_messages/copy_data.py        |  4 +-
 .../messages/frontend_messages/copy_done.py        |  4 +-
 .../messages/frontend_messages/copy_fail.py        |  4 +-
 .../messages/frontend_messages/copy_stream.py      |  4 +-
 .../vertica/messages/frontend_messages/describe.py |  4 +-
 .../vertica/messages/frontend_messages/execute.py  |  4 +-
 .../vertica/messages/frontend_messages/flush.py    |  4 +-
 .../vertica/messages/frontend_messages/parse.py    |  4 +-
 .../vertica/messages/frontend_messages/password.py |  4 +-
 .../vertica/messages/frontend_messages/query.py    |  9 +--
 .../messages/frontend_messages/ssl_request.py      |  2 +-
 .../vertica/messages/frontend_messages/startup.py  |  8 +--
 .../vertica/messages/frontend_messages/sync.py     |  4 +-
 .../messages/frontend_messages/terminate.py        |  4 +-
 vertica_python/vertica/messages/message.py         | 14 ++---
 52 files changed, 313 insertions(+), 214 deletions(-)

diff --git a/README.md b/README.md
index 1b7b030..b2dddaf 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,8 @@
 
 [![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.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
 
@@ -13,7 +15,7 @@ vertica-python is a native Python adapter for the Vertica (http://www.vertica.co
 
 vertica-python is currently in beta stage; it has been tested for functionality and has a very basic test suite. Please use with caution, and feel free to submit issues and/or pull requests (after running the unit tests).
 
-vertica-python has been tested with Vertica 6.1.2/7.0.0+ and Python 2.6/2.7.
+vertica-python has been tested with Vertica 6.1.2/7.0.0+ and Python 2.7/3.4.
 
 
 ## Installation
@@ -44,11 +46,13 @@ spin one up with Vagrant that uses the default credentials using
 instead; you can set the environment variables seen in
 `tests/test_commons.py`.
 
-    # install nose if you don't have it
-    pip install -r requirements_test.txt
+Assuming you have [tox](http://tox.readthedocs.io/) installed, all you
+have to do is run `tox`. It will run the unit tests using both python 2 and 3.
+
+If you run into an error like:
+```ERROR: InterpreterNotFound: python3.4```
 
-    # run tests
-    nosetests
+Edit the envlist property of tox.ini to use the version of python you have installed (eg py35)
 
 
 ## Usage
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index a60d073..0000000
--- a/requirements.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-python-dateutil>=1.5
-pytz
-ordereddict==1.1
diff --git a/requirements_test.txt b/requirements_test.txt
deleted file mode 100644
index 1b05401..0000000
--- a/requirements_test.txt
+++ /dev/null
@@ -1 +0,0 @@
-nose==1.3.6
diff --git a/setup.py b/setup.py
index bb8fcfc..78c1730 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.5.8',
+    version='0.6.2',
     description='A native Python client for the Vertica database.',
     author='Justin Berka, Alex Kim, Kenneth Tran',
     author_email='justin.berka at gmail.com, alex.kim at uber.com, tran at uber.com',
@@ -18,7 +18,12 @@ setup(
     keywords="database vertica",
     packages=find_packages(),
     license="MIT",
-    install_requires=['python-dateutil>=1.5', 'pytz', 'ordereddict==1.1'],
+    install_requires=[
+        'python-dateutil>=1.5',
+        'pytz',
+        'ordereddict==1.1',
+        'future'
+    ],
     extras_require={'namedparams': ['psycopg2>=2.5.1']},
     classifiers=[
         "Development Status :: 3 - Alpha",
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..c1d6e9b
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,9 @@
+[tox]
+envlist = py27,py34
+
+[testenv]
+commands =
+	nosetests
+deps =
+	nose==1.3.6
+	psycopg2>=2.5.1
diff --git a/vertica_python/__init__.py b/vertica_python/__init__.py
index c0fb885..a5fac1d 100644
--- a/vertica_python/__init__.py
+++ b/vertica_python/__init__.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 from vertica_python.vertica.connection import Connection
 
@@ -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, 5, 8)
+version_info = (0, 6, 2)
 
 __version__ = '.'.join(map(str, version_info))
 
diff --git a/vertica_python/datatypes.py b/vertica_python/datatypes.py
index c459295..89fe296 100644
--- a/vertica_python/datatypes.py
+++ b/vertica_python/datatypes.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 from datetime import datetime
 from datetime import timedelta
diff --git a/vertica_python/errors.py b/vertica_python/errors.py
index 1b9f842..666dcbe 100644
--- a/vertica_python/errors.py
+++ b/vertica_python/errors.py
@@ -1,14 +1,16 @@
-from __future__ import absolute_import
 
-import exceptions
+
+import sys
+if sys.version_info < (3,):
+    import exceptions
 import re
 
 
-class Error(exceptions.StandardError):
+class Error(Exception):
     pass
 
 
-class Warning(exceptions.StandardError):
+class Warning(Exception):
     pass
 
 
@@ -107,6 +109,10 @@ class VerticaSyntaxError(QueryError):
     pass
 
 
+class MissingSchema(QueryError):
+    pass
+
+
 class MissingRelation(QueryError):
     pass
 
@@ -127,14 +133,20 @@ class InvalidDatetimeFormat(QueryError):
     pass
 
 
+class DuplicateObject(QueryError):
+    pass
+
+
 QUERY_ERROR_CLASSES = {
-    '55V03': LockFailure,
-    '53000': InsufficientResources,
-    '53200': OutOfMemory,
-    '42601': VerticaSyntaxError,
-    '42V01': MissingRelation,
-    '42703': MissingColumn,
-    '22V04': CopyRejected,
-    '42501': PermissionDenied,
-    '22007': InvalidDatetimeFormat
+    b'55V03': LockFailure,
+    b'53000': InsufficientResources,
+    b'53200': OutOfMemory,
+    b'42601': VerticaSyntaxError,
+    b'3F000': MissingSchema,
+    b'42V01': MissingRelation,
+    b'42703': MissingColumn,
+    b'22V04': CopyRejected,
+    b'42501': PermissionDenied,
+    b'22007': InvalidDatetimeFormat,
+    b'42710': DuplicateObject
 }
diff --git a/vertica_python/tests/basic_tests.py b/vertica_python/tests/basic_tests.py
index 0593e40..dbc72de 100644
--- a/vertica_python/tests/basic_tests.py
+++ b/vertica_python/tests/basic_tests.py
@@ -2,7 +2,7 @@ import unittest
 import logging
 import tempfile
 
-from test_commons import conn_info
+from .test_commons import conn_info
 
 import vertica_python
 from vertica_python import errors
@@ -184,7 +184,7 @@ class TestVerticaPython(unittest.TestCase):
         cur2 = conn.cursor()
     
         f = tempfile.TemporaryFile()
-        f.write("1,foo\n2,bar")
+        f.write(b"1,foo\n2,bar")
         # move rw pointer to top of file
         f.seek(0)
         cur.copy(""" COPY vertica_python_unit_test (a, b) from stdin DELIMITER ',' """,  f)
diff --git a/vertica_python/tests/date_tests.py b/vertica_python/tests/date_tests.py
index 90e4486..4477165 100644
--- a/vertica_python/tests/date_tests.py
+++ b/vertica_python/tests/date_tests.py
@@ -1,5 +1,5 @@
 from datetime import date, datetime
-from test_commons import *
+from .test_commons import *
 from vertica_python import errors
 from vertica_python.vertica.column import timestamp_parse
 
diff --git a/vertica_python/tests/error_tests.py b/vertica_python/tests/error_tests.py
new file mode 100644
index 0000000..e3c27bd
--- /dev/null
+++ b/vertica_python/tests/error_tests.py
@@ -0,0 +1,62 @@
+from .test_commons import conn_info, VerticaTestCase
+from .. import connect
+from .. import errors
+
+
+class ErrorTestCase(VerticaTestCase):
+
+    def test_missing_schema(self):
+
+        query = "SELECT 1 FROM missing_schema.table"
+
+        with connect(**conn_info) as conn:
+            cur = conn.cursor()
+
+            failed = False
+
+            try:
+                cur.execute(query)
+            except errors.MissingSchema:
+                failed = True
+
+            assert failed is True
+
+    def test_missing_relation(self):
+
+        query = "SELECT 1 FROM missing_table"
+
+        with connect(**conn_info) as conn:
+            cur = conn.cursor()
+
+            failed = False
+
+            try:
+                cur.execute(query)
+            except errors.MissingRelation:
+                failed = True
+
+            assert failed is True
+
+    def test_duplicate_object(self):
+
+        create = "CREATE TABLE test_table (a BOOLEAN)"
+        drop = "DROP TABLE test_table"
+
+        with connect(**conn_info) as conn:
+            cur = conn.cursor()
+
+            failed = False
+
+            cur.execute(create)
+
+            try:
+                cur.execute(create)
+            except errors.DuplicateObject:
+                failed = True
+            finally:
+                try:
+                    cur.execute(drop)
+                except errors.MissingRelation:
+                    pass
+
+            assert failed is True
diff --git a/vertica_python/tests/unicode_tests.py b/vertica_python/tests/unicode_tests.py
index 42a5bc6..adf1314 100644
--- a/vertica_python/tests/unicode_tests.py
+++ b/vertica_python/tests/unicode_tests.py
@@ -3,10 +3,22 @@ from .. import connect
 
 
 class UnicodeTestCase(VerticaTestCase):
+    def test_unicode_query(self):
+        value = u'\u16a0'
+        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_unicode_named_parameter_binding(self):
         key = u'\u16a0'
-        value = 1
-        query = u"SELECT :%s" % key
+        value = u'\u16b1'
+        query = u"SELECT :{}".format(key)
 
         with connect(**conn_info) as conn:
             cur = conn.cursor()
diff --git a/vertica_python/vertica/column.py b/vertica_python/vertica/column.py
index 7dd4df5..91c41dd 100644
--- a/vertica_python/vertica/column.py
+++ b/vertica_python/vertica/column.py
@@ -1,8 +1,9 @@
-from __future__ import absolute_import
+
 
 from collections import namedtuple
 import re
 
+from builtins import str
 from decimal import Decimal
 from datetime import date
 from datetime import datetime
@@ -78,10 +79,10 @@ def date_parse(s):
     :return: an instance of datetime.date
     :raises NotSupportedError when a date Before Christ is encountered
     """
-    if s.endswith(' BC'):
-        raise errors.NotSupportedError('Dates Before Christ are not supported. Got: ' + s)
+    if s.endswith(b' BC'):
+        raise errors.NotSupportedError('Dates Before Christ are not supported. Got: ' + str(s, 'utf-8'))
 
-    return date(*map(lambda x: int(x), s.split('-')))
+    return date(*map(lambda x: int(x), s.split(b'-')))
 
 ColumnTuple = namedtuple(
     'Column',
@@ -105,8 +106,8 @@ class Column(object):
             ('bool', lambda s: s == 't'),
             ('integer', lambda s: int(s)),
             ('float', lambda s: float(s)),
-            ('char', lambda s: unicode(s, 'utf-8', unicode_error)),
-            ('varchar', lambda s: unicode(s, 'utf-8', unicode_error)),
+            ('char', lambda s: str(s, 'utf-8', unicode_error)),
+            ('varchar', lambda s: str(s, 'utf-8', unicode_error)),
             ('date', date_parse),
             ('time', None),
             ('timestamp', timestamp_parse),
@@ -165,7 +166,7 @@ class Column(object):
         return self.props.__str__()
 
     def __unicode__(self):
-        return unicode(self.props.__str__())
+        return str(self.props.__str__())
 
     def __repr__(self):
         return self.props.__str__()
diff --git a/vertica_python/vertica/connection.py b/vertica_python/vertica/connection.py
index 1865fbf..eb70c4d 100644
--- a/vertica_python/vertica/connection.py
+++ b/vertica_python/vertica/connection.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 import logging
 import select
@@ -7,6 +7,8 @@ import ssl
 
 from struct import unpack
 
+from builtins import str
+
 import vertica_python.errors as errors
 import vertica_python.vertica.messages as messages
 
@@ -14,6 +16,7 @@ from vertica_python.vertica.messages.message import BackendMessage
 
 from vertica_python.vertica.cursor import Cursor
 from vertica_python.errors import SSLNotSupported
+import collections
 
 logger = logging.getLogger('vertica')
 
@@ -24,7 +27,7 @@ class Connection(object):
 
         options = options or {}
         self.options = dict(
-            (key, value) for key, value in options.iteritems() if value is not None
+            (key, value) for key, value in options.items() if value is not None
         )
 
         # we only support one cursor per connection
@@ -37,13 +40,13 @@ class Connection(object):
     def __enter__(self):
         return self
 
-    def __exit__(self, type, value, traceback):
+    def __exit__(self, type_, value, traceback):
         try:
             # if there's no outstanding transaction, we can simply close the connection
             if self.transaction_status in (None, 'in_transaction'):
                 return
 
-            if type is not None:
+            if type_ is not None:
                 self.rollback()
             else:
                 self.commit()
@@ -110,15 +113,15 @@ class Connection(object):
             from ssl import CertificateError, SSLError
             raw_socket.sendall(messages.SslRequest().to_bytes())
             response = raw_socket.recv(1)
-            if response == 'S':
+            if response in ('S', b'S'):
                 try:
                     if isinstance(ssl_options, ssl.SSLContext):
                         raw_socket = ssl_options.wrap_socket(raw_socket, server_hostname=host)
                     else:
                         raw_socket = ssl.wrap_socket(raw_socket)
-                except CertificateError, e:
+                except CertificateError as e:
                     raise errors.ConnectionError('SSL: ' + e.message)
-                except SSLError, e:
+                except SSLError as e:
                     raise errors.ConnectionError('SSL: ' + e.reason)
             else:
                 raise SSLNotSupported("SSL requested but not supported by server")
@@ -141,7 +144,7 @@ class Connection(object):
 
         is_stream = hasattr(message, "read_bytes")
 
-        if (hasattr(message, 'to_bytes') is False or callable(getattr(message, 'to_bytes')) is False) and not is_stream:
+        if (hasattr(message, 'to_bytes') is False or isinstance(getattr(message, 'to_bytes'), collections.Callable) is False) and not is_stream:
             raise TypeError("invalid message: ({0})".format(message))
 
         logger.debug('=> %s', message)
@@ -158,12 +161,12 @@ class Connection(object):
 
                     self._socket().sendall(data)
 
-        except Exception, e:
+        except Exception as e:
             self.close_socket()
-            if e.message == 'unsupported authentication method: 9':
+            if str(e) == 'unsupported authentication method: 9':
                 raise errors.ConnectionError('Error during authentication. Your password might be expired.')
             else:
-                raise errors.ConnectionError(e.message)
+                raise errors.ConnectionError(str(e))
 
     def close_socket(self):
         try:
@@ -178,19 +181,19 @@ class Connection(object):
 
     def read_message(self):
         try:
-            type = self.read_bytes(1)
+            type_ = self.read_bytes(1)
             size = unpack('!I', self.read_bytes(4))[0]
 
             if size < 4:
                 raise errors.MessageError(
                     "Bad message size: {0}".format(size)
                 )
-            message = BackendMessage.factory(type, self.read_bytes(size - 4))
+            message = BackendMessage.factory(type_, self.read_bytes(size - 4))
             logger.debug('<= %s', message)
             return message
         except (SystemError, IOError) as e:
             self.close_socket()
-            raise errors.ConnectionError(e.message)
+            raise errors.ConnectionError(str(e))
 
     def process_message(self, message):
         if isinstance(message, messages.ErrorResponse):
@@ -221,7 +224,7 @@ class Connection(object):
 
     def __str__(self):
         safe_options = dict(
-            (key, value) for key, value in self.options.iteritems() if key != 'password'
+            (key, value) for key, value in self.options.items() if key != 'password'
         )
         s1 = "<Vertica.Connection:{0} parameters={1} backend_pid={2}, ".format(
             id(self), self.parameters, self.backend_pid
@@ -233,12 +236,12 @@ class Connection(object):
         return s1 + s2
 
     def read_bytes(self, n):
-        results = ''
+        results = bytes()
         while len(results) < n:
-            bytes = self._socket().recv(n - len(results))
-            if not bytes:
+            bytes_ = self._socket().recv(n - len(results))
+            if not bytes_:
                 raise errors.ConnectionError("Connection closed by Vertica")
-            results = results + bytes
+            results = results + bytes_
         return results
 
     def startup_connection(self):
diff --git a/vertica_python/vertica/cursor.py b/vertica_python/vertica/cursor.py
index 611ffb9..cedc0b5 100644
--- a/vertica_python/vertica/cursor.py
+++ b/vertica_python/vertica/cursor.py
@@ -1,9 +1,10 @@
-from __future__ import absolute_import
+
 
 import re
 import logging
 
-from ordereddict import OrderedDict
+from collections import OrderedDict
+from builtins import str
 
 import vertica_python.errors as errors
 
@@ -32,7 +33,7 @@ class Cursor(object):
     def __enter__(self):
         return self
 
-    def __exit__(self, type, value, traceback):
+    def __exit__(self, type_, value, traceback):
         self.close()
 
     #
@@ -59,19 +60,19 @@ class Cursor(object):
                 for key in parameters:
                     param = parameters[key]
                     # Make sure adapt() behaves properly
-                    if isinstance(param, unicode):
+                    if isinstance(param, str):
                         v = adapt(param.encode('utf8')).getquoted()
                     else:
                         v = adapt(param).getquoted()
 
                     # Using a regex with word boundary to correctly handle params with similar names
                     # such as :s and :start
-                    match_str = u':%s\\b' % unicode(key)
+                    match_str = u':%s\\b' % str(key)
                     operation = re.sub(match_str, v.decode('utf-8'), operation, flags=re.UNICODE)
             elif isinstance(parameters, tuple):
                 tlist = []
                 for p in parameters:
-                    if isinstance(p, unicode):
+                    if isinstance(p, str):
                         tlist.append(adapt(p.encode('utf8')).getquoted())
                     else:
                         tlist.append(adapt(p).getquoted())
@@ -91,7 +92,7 @@ class Cursor(object):
             if isinstance(message, messages.ErrorResponse):
                 raise errors.QueryError.from_error_response(message, operation)
             elif isinstance(message, messages.RowDescription):
-                self.description = map(lambda fd: Column(fd, self.unicode_error), message.fields)
+                self.description = list(map(lambda fd: Column(fd, self.unicode_error), message.fields))
             elif isinstance(message, messages.DataRow):
                 break
             elif isinstance(message, messages.ReadyForQuery):
@@ -216,6 +217,10 @@ class Cursor(object):
 
         while True:
             message = self.connection.read_message()
+
+            if isinstance(message, messages.ErrorResponse):
+                raise errors.QueryError.from_error_response(message, sql)
+
             self.connection.process_message(message=message)
             if isinstance(message, messages.ReadyForQuery):
                 break
diff --git a/vertica_python/vertica/messages/__init__.py b/vertica_python/vertica/messages/__init__.py
index d15ed69..7168246 100644
--- a/vertica_python/vertica/messages/__init__.py
+++ b/vertica_python/vertica/messages/__init__.py
@@ -1,39 +1,39 @@
-from backend_messages.authentication import Authentication
-from backend_messages.backend_key_data import BackendKeyData
-from backend_messages.bind_complete import BindComplete
-from backend_messages.close_complete import CloseComplete
-from backend_messages.command_complete import CommandComplete
-from backend_messages.copy_in_response import CopyInResponse
-from backend_messages.data_row import DataRow
-from backend_messages.empty_query_response import EmptyQueryResponse
-from backend_messages.error_response import ErrorResponse
-from backend_messages.no_data import NoData
-from backend_messages.notice_response import NoticeResponse
-from backend_messages.parameter_description import ParameterDescription
-from backend_messages.parameter_status import ParameterStatus
-from backend_messages.parse_complete import ParseComplete
-from backend_messages.portal_suspended import PortalSuspended
-from backend_messages.ready_for_query import ReadyForQuery
-from backend_messages.row_description import RowDescription
-from backend_messages.unknown import Unknown
+from .backend_messages.authentication import Authentication
+from .backend_messages.backend_key_data import BackendKeyData
+from .backend_messages.bind_complete import BindComplete
+from .backend_messages.close_complete import CloseComplete
+from .backend_messages.command_complete import CommandComplete
+from .backend_messages.copy_in_response import CopyInResponse
+from .backend_messages.data_row import DataRow
+from .backend_messages.empty_query_response import EmptyQueryResponse
+from .backend_messages.error_response import ErrorResponse
+from .backend_messages.no_data import NoData
+from .backend_messages.notice_response import NoticeResponse
+from .backend_messages.parameter_description import ParameterDescription
+from .backend_messages.parameter_status import ParameterStatus
+from .backend_messages.parse_complete import ParseComplete
+from .backend_messages.portal_suspended import PortalSuspended
+from .backend_messages.ready_for_query import ReadyForQuery
+from .backend_messages.row_description import RowDescription
+from .backend_messages.unknown import Unknown
 
-from frontend_messages.bind import Bind
-from frontend_messages.cancel_request import CancelRequest
-from frontend_messages.close import Close
-from frontend_messages.copy_data import CopyData
-from frontend_messages.copy_stream import CopyStream
-from frontend_messages.copy_done import CopyDone
-from frontend_messages.copy_fail import CopyFail
-from frontend_messages.describe import Describe
-from frontend_messages.execute import Execute
-from frontend_messages.flush import Flush
-from frontend_messages.parse import Parse
-from frontend_messages.password import Password
-from frontend_messages.query import Query
-from frontend_messages.ssl_request import SslRequest
-from frontend_messages.startup import Startup
-from frontend_messages.sync import Sync
-from frontend_messages.terminate import Terminate
+from .frontend_messages.bind import Bind
+from .frontend_messages.cancel_request import CancelRequest
+from .frontend_messages.close import Close
+from .frontend_messages.copy_data import CopyData
+from .frontend_messages.copy_stream import CopyStream
+from .frontend_messages.copy_done import CopyDone
+from .frontend_messages.copy_fail import CopyFail
+from .frontend_messages.describe import Describe
+from .frontend_messages.execute import Execute
+from .frontend_messages.flush import Flush
+from .frontend_messages.parse import Parse
+from .frontend_messages.password import Password
+from .frontend_messages.query import Query
+from .frontend_messages.ssl_request import SslRequest
+from .frontend_messages.startup import Startup
+from .frontend_messages.sync import Sync
+from .frontend_messages.terminate import Terminate
 
 __all__ = ["Authentication", "BackendKeyData", "BindComplete", "CloseComplete", "CommandComplete",
            "CopyInResponse", "DataRow", "EmptyQueryResponse", "ErrorResponse", "NoData", "NoticeResponse",
diff --git a/vertica_python/vertica/messages/backend_messages/authentication.py b/vertica_python/vertica/messages/backend_messages/authentication.py
index 54add1a..3e0a93e 100644
--- a/vertica_python/vertica/messages/backend_messages/authentication.py
+++ b/vertica_python/vertica/messages/backend_messages/authentication.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 from struct import unpack
 
@@ -27,4 +27,4 @@ class Authentication(BackendMessage):
             self.auth_data = other
 
 
-Authentication._message_id('R')
+Authentication._message_id(b'R')
diff --git a/vertica_python/vertica/messages/backend_messages/backend_key_data.py b/vertica_python/vertica/messages/backend_messages/backend_key_data.py
index 317d450..d2f8316 100644
--- a/vertica_python/vertica/messages/backend_messages/backend_key_data.py
+++ b/vertica_python/vertica/messages/backend_messages/backend_key_data.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 from struct import unpack
 
@@ -13,4 +13,4 @@ class BackendKeyData(BackendMessage):
         self.key = unpacked[1]
 
 
-BackendKeyData._message_id('K')
+BackendKeyData._message_id(b'K')
diff --git a/vertica_python/vertica/messages/backend_messages/bind_complete.py b/vertica_python/vertica/messages/backend_messages/bind_complete.py
index 5d25e1d..12c352a 100644
--- a/vertica_python/vertica/messages/backend_messages/bind_complete.py
+++ b/vertica_python/vertica/messages/backend_messages/bind_complete.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 from vertica_python.vertica.messages.message import BackendMessage
 
@@ -7,4 +7,4 @@ class BindComplete(BackendMessage):
     pass
 
 
-BindComplete._message_id('2')
+BindComplete._message_id(b'2')
diff --git a/vertica_python/vertica/messages/backend_messages/close_complete.py b/vertica_python/vertica/messages/backend_messages/close_complete.py
index fea59dd..4ff7ddf 100644
--- a/vertica_python/vertica/messages/backend_messages/close_complete.py
+++ b/vertica_python/vertica/messages/backend_messages/close_complete.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 from vertica_python.vertica.messages.message import BackendMessage
 
@@ -7,4 +7,4 @@ class CloseComplete(BackendMessage):
     pass
 
 
-CloseComplete._message_id('3')
+CloseComplete._message_id(b'3')
diff --git a/vertica_python/vertica/messages/backend_messages/command_complete.py b/vertica_python/vertica/messages/backend_messages/command_complete.py
index 92873f2..802577c 100644
--- a/vertica_python/vertica/messages/backend_messages/command_complete.py
+++ b/vertica_python/vertica/messages/backend_messages/command_complete.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 import re
 
@@ -13,15 +13,15 @@ class CommandComplete(BackendMessage):
 
         data = unpack('{0}sx'.format(len(data) - 1), data)[0]
 
-        if re.match("INSERT", data) is not None:
-            splitstr = data.split(' ', 3)
+        if re.match(b"INSERT", data) is not None:
+            splitstr = data.split(b' ', 3)
             self.tag = splitstr[0]
             if len(splitstr) >= 2:
                 self.oid = int(splitstr[1])
             if len(splitstr) >= 3:
                 self.rows = int(splitstr[2])
-        elif re.match("(DELETE|UPDATE|MOVE|FETCH|COPY)", data) is not None:
-            splitstr = data.split(' ', 2)
+        elif re.match(b"(DELETE|UPDATE|MOVE|FETCH|COPY)", data) is not None:
+            splitstr = data.split(b' ', 2)
             self.tag = splitstr[0]
             if len(splitstr) >= 2:
                 self.rows = int(splitstr[1])
@@ -29,4 +29,4 @@ class CommandComplete(BackendMessage):
             self.tag = data
 
 
-CommandComplete._message_id('C')
+CommandComplete._message_id(b'C')
diff --git a/vertica_python/vertica/messages/backend_messages/copy_in_response.py b/vertica_python/vertica/messages/backend_messages/copy_in_response.py
index 1566035..71c2bc2 100644
--- a/vertica_python/vertica/messages/backend_messages/copy_in_response.py
+++ b/vertica_python/vertica/messages/backend_messages/copy_in_response.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 from struct import unpack
 
@@ -8,9 +8,9 @@ from vertica_python.vertica.messages.message import BackendMessage
 class CopyInResponse(BackendMessage):
 
     def __init__(self, data):
-        values = unpack('!B{0}H'.format((len(data) - 1)/2), data)
+        values = unpack('!B{0}H'.format((len(data) - 1)//2), data)
         self.format = values[0]
         self.column_formats = values[2::]
 
 
-CopyInResponse._message_id('G')
+CopyInResponse._message_id(b'G')
diff --git a/vertica_python/vertica/messages/backend_messages/data_row.py b/vertica_python/vertica/messages/backend_messages/data_row.py
index 52eec1a..8c7fbc5 100644
--- a/vertica_python/vertica/messages/backend_messages/data_row.py
+++ b/vertica_python/vertica/messages/backend_messages/data_row.py
@@ -1,5 +1,6 @@
-from __future__ import absolute_import
 
+
+from builtins import range
 from struct import unpack, unpack_from
 
 from vertica_python.vertica.messages.message import BackendMessage
@@ -12,7 +13,7 @@ class DataRow(BackendMessage):
         field_count = unpack('!H', data[0:2])[0]
         pos = 2
 
-        for i in xrange(field_count):
+        for i in range(field_count):
             size = unpack_from('!I', data, pos)[0]
 
             if size == 4294967295:
@@ -25,4 +26,4 @@ class DataRow(BackendMessage):
             pos += (4 + max(size, 0))
 
 
-DataRow._message_id('D')
+DataRow._message_id(b'D')
diff --git a/vertica_python/vertica/messages/backend_messages/empty_query_response.py b/vertica_python/vertica/messages/backend_messages/empty_query_response.py
index fbe68aa..9b3eb20 100644
--- a/vertica_python/vertica/messages/backend_messages/empty_query_response.py
+++ b/vertica_python/vertica/messages/backend_messages/empty_query_response.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 from vertica_python.vertica.messages.message import BackendMessage
 
@@ -7,4 +7,4 @@ class EmptyQueryResponse(BackendMessage):
     pass
 
 
-EmptyQueryResponse._message_id('I')
+EmptyQueryResponse._message_id(b'I')
diff --git a/vertica_python/vertica/messages/backend_messages/error_response.py b/vertica_python/vertica/messages/backend_messages/error_response.py
index 471c16e..cf03e2a 100644
--- a/vertica_python/vertica/messages/backend_messages/error_response.py
+++ b/vertica_python/vertica/messages/backend_messages/error_response.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 from vertica_python.vertica.messages.message import BackendMessage
 from vertica_python.vertica.messages.backend_messages.notice_response import NoticeResponse
@@ -8,4 +8,4 @@ class ErrorResponse(NoticeResponse, BackendMessage):
     pass
 
 
-ErrorResponse._message_id('E')
+ErrorResponse._message_id(b'E')
diff --git a/vertica_python/vertica/messages/backend_messages/no_data.py b/vertica_python/vertica/messages/backend_messages/no_data.py
index b9c3c7c..78086ff 100644
--- a/vertica_python/vertica/messages/backend_messages/no_data.py
+++ b/vertica_python/vertica/messages/backend_messages/no_data.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 from vertica_python.vertica.messages.message import BackendMessage
 
@@ -7,4 +7,4 @@ class NoData(BackendMessage):
     pass
 
 
-NoData._message_id('n')
+NoData._message_id(b'n')
diff --git a/vertica_python/vertica/messages/backend_messages/notice_response.py b/vertica_python/vertica/messages/backend_messages/notice_response.py
index e0dc35c..fadf7ff 100644
--- a/vertica_python/vertica/messages/backend_messages/notice_response.py
+++ b/vertica_python/vertica/messages/backend_messages/notice_response.py
@@ -1,6 +1,4 @@
-from __future__ import absolute_import
 
-import string
 
 from struct import unpack_from
 
@@ -10,18 +8,18 @@ from vertica_python.vertica.messages.message import BackendMessage
 class NoticeResponse(BackendMessage):
 
     FIELDS_DEFINITIONS = [
-        {'type': 'q', 'name': "Internal Query", 'method': 'internal_query'},
-        {'type': 'S', 'name': "Severity", 'method': 'severity'},
-        {'type': 'M', 'name': "Message", 'method': 'message'},
-        {'type': 'C', 'name': "Sqlstate", 'method': 'sqlstate'},
-        {'type': 'D', 'name': "Detail", 'method': 'detail'},
-        {'type': 'H', 'name': "Hint", 'method': 'hint'},
-        {'type': 'P', 'name': "Position", 'method': 'position'},
-        {'type': 'W', 'name': "Where", 'method': 'where'},
-        {'type': 'p', 'name': "Internal Position", 'method': 'internal_position'},
-        {'type': 'R', 'name': "Routine", 'method': 'routine'},
-        {'type': 'F', 'name': "File", 'method': 'file'},
-        {'type': 'L', 'name': "Line", 'method': 'line'}
+        {'type': b'q', 'name': "Internal Query", 'method': 'internal_query'},
+        {'type': b'S', 'name': "Severity", 'method': 'severity'},
+        {'type': b'M', 'name': "Message", 'method': 'message'},
+        {'type': b'C', 'name': "Sqlstate", 'method': 'sqlstate'},
+        {'type': b'D', 'name': "Detail", 'method': 'detail'},
+        {'type': b'H', 'name': "Hint", 'method': 'hint'},
+        {'type': b'P', 'name': "Position", 'method': 'position'},
+        {'type': b'W', 'name': "Where", 'method': 'where'},
+        {'type': b'p', 'name': "Internal Position", 'method': 'internal_position'},
+        {'type': b'R', 'name': "Routine", 'method': 'routine'},
+        {'type': b'F', 'name': "File", 'method': 'file'},
+        {'type': b'L', 'name': "Line", 'method': 'line'}
     ]
 
     def FIELDS(self):
@@ -35,7 +33,7 @@ class NoticeResponse(BackendMessage):
 
         pos = 0
         while pos < len(data) - 1:
-            null_byte = string.find(data, '\x00', pos)
+            null_byte = data.find(b'\x00', pos)
 
             # This will probably work
             unpacked = unpack_from('c{0}sx'.format(null_byte - 1 - pos), data, pos)
@@ -58,4 +56,4 @@ class NoticeResponse(BackendMessage):
         return ', '.join(ordered)
 
 
-NoticeResponse._message_id('N')
+NoticeResponse._message_id(b'N')
diff --git a/vertica_python/vertica/messages/backend_messages/parameter_description.py b/vertica_python/vertica/messages/backend_messages/parameter_description.py
index 0c0b9fb..91113f1 100644
--- a/vertica_python/vertica/messages/backend_messages/parameter_description.py
+++ b/vertica_python/vertica/messages/backend_messages/parameter_description.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+
 
 from struct import unpack, unpack_from
 
@@ -14,4 +14,4 @@ class ParameterDescription(BackendMessage):
         self.parameter_types = [Column.data_types[dtid] for dtid in parameter_type_ids]
 
 
-ParameterDescription._message_id('t')
+ParameterDescription._message_id(b't')
diff --git a/vertica_python/vertica/messages/backend_messages/parameter_status.py b/vertica_python/vertica/messages/backend_messages/parameter_status.py
index 06c952a..c96b4b2 100644
--- a/vertica_python/vertica/messages/backend_messages/parameter_status.py
+++ b/vertica_python/vertica/messages/backend_messages/parameter_status.py
@@ -1,6 +1,4 @@
... 453 lines suppressed ...

-- 
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