From a04d4ec5fc5ab96256f5d243ed62d6526ed705e7 Mon Sep 17 00:00:00 2001 From: Kenneth Tran Date: Sat, 2 May 2015 16:05:36 -0700 Subject: [PATCH 1/2] Fix incomplete processing for write queries --- README.md | 1 - vertica_python/vertica/connection.py | 2 ++ vertica_python/vertica/cursor.py | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 49915d5b..60f24e4d 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,6 @@ connection = connect({ 'user': 'some_user', 'password': 'some_password', 'database': 'a_database' - }) cur = connection.cursor() diff --git a/vertica_python/vertica/connection.py b/vertica_python/vertica/connection.py index 0ddcece4..326742b4 100644 --- a/vertica_python/vertica/connection.py +++ b/vertica_python/vertica/connection.py @@ -186,6 +186,8 @@ def process_message(self, message): self.parameters[message.name] = message.value elif isinstance(message, messages.ReadyForQuery): self.transaction_status = message.transaction_status + elif isinstance(message, messages.CommandComplete): + pass else: raise errors.MessageError("Unhandled message: {0}".format(message)) diff --git a/vertica_python/vertica/cursor.py b/vertica_python/vertica/cursor.py index 9c2c5f7e..d839feee 100644 --- a/vertica_python/vertica/cursor.py +++ b/vertica_python/vertica/cursor.py @@ -70,7 +70,6 @@ def execute(self, operation, parameters=None): elif isinstance(message, messages.RowDescription): self.description = map(lambda fd: Column(fd), message.fields) elif isinstance(message, messages.DataRow) \ - or isinstance(message, messages.CommandComplete) \ or isinstance(message, messages.ReadyForQuery): self._message = message # cache the message because there's no way to undo the read break From c573588f2b28c45e50cad1357b1d48e5793e367c Mon Sep 17 00:00:00 2001 From: Kenneth Tran Date: Mon, 4 May 2015 12:00:28 -0700 Subject: [PATCH 2/2] call connection.process_message when message is not a data row in fetchone() --- vertica_python/vertica/cursor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vertica_python/vertica/cursor.py b/vertica_python/vertica/cursor.py index d839feee..269cd6c3 100644 --- a/vertica_python/vertica/cursor.py +++ b/vertica_python/vertica/cursor.py @@ -82,6 +82,8 @@ def fetchone(self): row = self.row_formatter(self._message) self._message = self.connection.read_message() return row + else: + self.connection.process_message(self._message) def iterate(self): row = self.fetchone()