Commit 65ed3c64 authored by Lukáš Lalinský's avatar Lukáš Lalinský

Explicitly open a new connection (avatica 1.5, fixes #1)

parent 0602d34f
......@@ -91,6 +91,15 @@ working Phoenix database and set the ``PHOENIXDB_TEST_DB_URL`` environment varia
export PHOENIXDB_TEST_DB_URL='http://localhost:8765/'
nosetests
Phoenix 4.7
-----------
Phoenix 4.7 uses a protobuf-based serialization by default. This library only supports
JSON serializatoin for now. In order for the library to work with Phoenix 4.7, you need
to start the query server like this::
./bin/queryserver.py start -Dphoenix.queryserver.serialization=JSON
Known issues
------------
......
......@@ -96,6 +96,7 @@ def parse_error_page(html):
AVATICA_1_2_0 = (1, 2, 0)
AVATICA_1_3_0 = (1, 3, 0)
AVATICA_1_4_0 = (1, 4, 0)
AVATICA_1_5_0 = (1, 5, 0)
class AvaticaClient(object):
......@@ -128,6 +129,8 @@ class AvaticaClient(object):
self.version = AVATICA_1_3_0
elif v in ('1.4.0', '1.4'):
self.version = AVATICA_1_4_0
elif v in ('1.5.0', '1.5'):
self.version = AVATICA_1_5_0
self.max_retries = max_retries if max_retries is not None else 3
self.connection = None
......@@ -297,6 +300,24 @@ class AvaticaClient(object):
request['connProps'].update(connProps)
return self._apply(request)['connProps']
def openConnection(self, connectionId, info=None):
"""Opens a new connection.
New in avatica 1.5.
:param connectionId:
ID of the connection to close.
"""
if self.version < AVATICA_1_5_0:
return
request = {
'request': 'openConnection',
'connectionId': connectionId,
}
if info is not None:
request['info'] = info
self._apply(request)
def closeConnection(self, connectionId):
"""Closes a connection.
......
......@@ -32,9 +32,9 @@ class Connection(object):
def __init__(self, client, **kwargs):
self._client = client
self._id = str(uuid.uuid4())
self._closed = False
self._cursors = []
self.open()
self.set_session(**kwargs)
def __del__(self):
......@@ -48,6 +48,11 @@ class Connection(object):
if not self._closed:
self.close()
def open(self):
"""Opens the connection."""
self._id = str(uuid.uuid4())
self._client.openConnection(self._id)
def close(self):
"""Closes the connection.
No further operations are allowed, either on the connection or any
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment