Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Commit

Permalink
Stop using the camelCase style in phoenixdb.avatica
Browse files Browse the repository at this point in the history
  • Loading branch information
lalinsky committed Jan 6, 2017
1 parent da4f392 commit 54a9ba4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 57 deletions.
94 changes: 47 additions & 47 deletions phoenixdb/avatica.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,23 +230,23 @@ def _apply(self, request_data, expected_response_type=None):

return message.wrapped_message

def getCatalogs(self, connectionId):
def get_catalogs(self, connection_id):
request = requests_pb2.CatalogsRequest()
request.connection_id = connectionId
request.connection_id = connection_id
return self._apply(request)

def getSchemas(self, connectionId, catalog=None, schemaPattern=None):
def get_schemas(self, connection_id, catalog=None, schemaPattern=None):
request = requests_pb2.SchemasRequest()
request.connection_id = connectionId
request.connection_id = connection_id
if catalog is not None:
request.catalog = catalog
if schemaPattern is not None:
request.schema_pattern = schemaPattern
return self._apply(request)

def getTables(self, connectionId, catalog=None, schemaPattern=None, tableNamePattern=None, typeList=None):
def get_tables(self, connection_id, catalog=None, schemaPattern=None, tableNamePattern=None, typeList=None):
request = requests_pb2.TablesRequest()
request.connection_id = connectionId
request.connection_id = connection_id
if catalog is not None:
request.catalog = catalog
if schemaPattern is not None:
Expand All @@ -260,9 +260,9 @@ def getTables(self, connectionId, catalog=None, schemaPattern=None, tableNamePat
request.has_type_list = typeList is not None
return self._apply(request)

def getColumns(self, connectionId, catalog=None, schemaPattern=None, tableNamePattern=None, columnNamePattern=None):
def get_columns(self, connection_id, catalog=None, schemaPattern=None, tableNamePattern=None, columnNamePattern=None):
request = requests_pb2.ColumnsRequest()
request.connection_id = connectionId
request.connection_id = connection_id
if catalog is not None:
request.catalog = catalog
if schemaPattern is not None:
Expand All @@ -273,20 +273,20 @@ def getColumns(self, connectionId, catalog=None, schemaPattern=None, tableNamePa
request.column_name_pattern = columnNamePattern
return self._apply(request)

def getTableTypes(self, connectionId):
def get_table_types(self, connection_id):
request = requests_pb2.TableTypesRequest()
request.connection_id = connectionId
request.connection_id = connection_id
return self._apply(request)

def getTypeInfo(self, connectionId):
def get_type_info(self, connection_id):
request = requests_pb2.TypeInfoRequest()
request.connection_id = connectionId
request.connection_id = connection_id
return self._apply(request)

def connectionSync(self, connectionId, connProps=None):
def connection_sync(self, connection_id, connProps=None):
"""Synchronizes connection properties with the server.
:param connectionId:
:param connection_id:
ID of the current connection.
:param connProps:
Expand All @@ -299,7 +299,7 @@ def connectionSync(self, connectionId, connProps=None):
connProps = {}

request = requests_pb2.ConnectionSyncRequest()
request.connection_id = connectionId
request.connection_id = connection_id
request.conn_props.auto_commit = connProps.get('autoCommit', False)
request.conn_props.has_auto_commit = True
request.conn_props.read_only = connProps.get('readOnly', False)
Expand All @@ -313,14 +313,14 @@ def connectionSync(self, connectionId, connProps=None):
response.ParseFromString(response_data)
return response.conn_props

def openConnection(self, connectionId, info=None):
def open_connection(self, connection_id, info=None):
"""Opens a new connection.
:param connectionId:
:param connection_id:
ID of the connection to open.
"""
request = requests_pb2.OpenConnectionRequest()
request.connection_id = connectionId
request.connection_id = connection_id
if info is not None:
# Info is a list of repeated pairs, setting a dict directly fails
for k, v in info.items():
Expand All @@ -330,55 +330,55 @@ def openConnection(self, connectionId, info=None):
response = responses_pb2.OpenConnectionResponse()
response.ParseFromString(response_data)

def closeConnection(self, connectionId):
def close_connection(self, connection_id):
"""Closes a connection.
:param connectionId:
:param connection_id:
ID of the connection to close.
"""
request = requests_pb2.CloseConnectionRequest()
request.connection_id = connectionId
request.connection_id = connection_id
self._apply(request)

def createStatement(self, connectionId):
def create_statement(self, connection_id):
"""Creates a new statement.
:param connectionId:
:param connection_id:
ID of the current connection.
:returns:
New statement ID.
"""
request = requests_pb2.CreateStatementRequest()
request.connection_id = connectionId
request.connection_id = connection_id

response_data = self._apply(request)
response = responses_pb2.CreateStatementResponse()
response.ParseFromString(response_data)
return response.statement_id

def closeStatement(self, connectionId, statementId):
def close_statement(self, connection_id, statement_id):
"""Closes a statement.
:param connectionId:
:param connection_id:
ID of the current connection.
:param statementId:
:param statement_id:
ID of the statement to close.
"""
request = requests_pb2.CloseStatementRequest()
request.connection_id = connectionId
request.statement_id = statementId
request.connection_id = connection_id
request.statement_id = statement_id

self._apply(request)

def prepareAndExecute(self, connectionId, statementId, sql, max_rows_total=None, first_frame_max_size=None):
def prepare_and_execute(self, connection_id, statement_id, sql, max_rows_total=None, first_frame_max_size=None):
"""Prepares and immediately executes a statement.
:param connectionId:
:param connection_id:
ID of the current connection.
:param statementId:
:param statement_id:
ID of the statement to prepare.
:param sql:
Expand All @@ -394,8 +394,8 @@ def prepareAndExecute(self, connectionId, statementId, sql, max_rows_total=None,
Result set with the signature of the prepared statement and the first frame data.
"""
request = requests_pb2.PrepareAndExecuteRequest()
request.connection_id = connectionId
request.statement_id = statementId
request.connection_id = connection_id
request.statement_id = statement_id
request.sql = sql
if max_rows_total is not None:
request.max_rows_total = max_rows_total
Expand All @@ -407,10 +407,10 @@ def prepareAndExecute(self, connectionId, statementId, sql, max_rows_total=None,
response.ParseFromString(response_data)
return response.results

def prepare(self, connectionId, sql, max_rows_total=None):
def prepare(self, connection_id, sql, max_rows_total=None):
"""Prepares a statement.
:param connectionId:
:param connection_id:
ID of the current connection.
:param sql:
Expand All @@ -423,7 +423,7 @@ def prepare(self, connectionId, sql, max_rows_total=None):
Signature of the prepared statement.
"""
request = requests_pb2.PrepareRequest()
request.connection_id = connectionId
request.connection_id = connection_id
request.sql = sql
if max_rows_total is not None:
request.max_rows_total = max_rows_total
Expand All @@ -433,17 +433,17 @@ def prepare(self, connectionId, sql, max_rows_total=None):
response.ParseFromString(response_data)
return response.statement

def execute(self, connectionId, statementId, signature, parameter_values=None, first_frame_max_size=None):
def execute(self, connection_id, statement_id, signature, parameter_values=None, first_frame_max_size=None):
"""Returns a frame of rows.
The frame describes whether there may be another frame. If there is not
another frame, the current iteration is done when we have finished the
rows in the this frame.
:param connectionId:
:param connection_id:
ID of the current connection.
:param statementId:
:param statement_id:
ID of the statement to fetch rows from.
:param signature:
Expand All @@ -459,8 +459,8 @@ def execute(self, connectionId, statementId, signature, parameter_values=None, f
Frame data, or ``None`` if there are no more.
"""
request = requests_pb2.ExecuteRequest()
request.statementHandle.id = statementId
request.statementHandle.connection_id = connectionId
request.statementHandle.id = statement_id
request.statementHandle.connection_id = connection_id
request.statementHandle.signature.CopyFrom(signature)
if parameter_values is not None:
request.parameter_values.extend(parameter_values)
Expand All @@ -473,17 +473,17 @@ def execute(self, connectionId, statementId, signature, parameter_values=None, f
response.ParseFromString(response_data)
return response.results

def fetch(self, connectionId, statementId, offset=0, frame_max_size=None):
def fetch(self, connection_id, statement_id, offset=0, frame_max_size=None):
"""Returns a frame of rows.
The frame describes whether there may be another frame. If there is not
another frame, the current iteration is done when we have finished the
rows in the this frame.
:param connectionId:
:param connection_id:
ID of the current connection.
:param statementId:
:param statement_id:
ID of the statement to fetch rows from.
:param offset:
Expand All @@ -496,8 +496,8 @@ def fetch(self, connectionId, statementId, offset=0, frame_max_size=None):
Frame data, or ``None`` if there are no more.
"""
request = requests_pb2.FetchRequest()
request.connection_id = connectionId
request.statement_id = statementId
request.connection_id = connection_id
request.statement_id = statement_id
request.offset = offset
if frame_max_size is not None:
request.frame_max_size = frame_max_size
Expand Down
12 changes: 6 additions & 6 deletions phoenixdb/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __exit__(self, exc_type, exc_value, traceback):
def open(self):
"""Opens the connection."""
self._id = str(uuid.uuid4())
self._client.openConnection(self._id, info=self._connection_args)
self._client.open_connection(self._id, info=self._connection_args)

def close(self):
"""Closes the connection.
Expand All @@ -77,7 +77,7 @@ def close(self):
cursor = cursor_ref()
if cursor is not None and not cursor._closed:
cursor.close()
self._client.closeConnection(self._id)
self._client.close_connection(self._id)
self._client.close()
self._closed = True

Expand Down Expand Up @@ -125,7 +125,7 @@ def set_session(self, autocommit=None, readonly=None):
props['autoCommit'] = bool(autocommit)
if readonly is not None:
props['readOnly'] = bool(readonly)
props = self._client.connectionSync(self._id, props)
props = self._client.connection_sync(self._id, props)
self._autocommit = props.auto_commit
self._readonly = props.read_only
self._transactionisolation = props.transaction_isolation
Expand All @@ -139,7 +139,7 @@ def autocommit(self):
def autocommit(self, value):
if self._closed:
raise ProgrammingError('the connection is already closed')
props = self._client.connectionSync(self._id, {'autoCommit': bool(value)})
props = self._client.connection_sync(self._id, {'autoCommit': bool(value)})
self._autocommit = props.auto_commit

@property
Expand All @@ -151,7 +151,7 @@ def readonly(self):
def readonly(self, value):
if self._closed:
raise ProgrammingError('the connection is already closed')
props = self._client.connectionSync(self._id, {'readOnly': bool(value)})
props = self._client.connection_sync(self._id, {'readOnly': bool(value)})
self._readonly = props.read_only

@property
Expand All @@ -162,7 +162,7 @@ def transactionisolation(self):
def transactionisolation(self, value):
if self._closed:
raise ProgrammingError('the connection is already closed')
props = self._client.connectionSync(self._id, {'transactionIsolation': bool(value)})
props = self._client.connection_sync(self._id, {'transactionIsolation': bool(value)})
self._transactionisolation = props.transaction_isolation

for name in errors.__all__:
Expand Down
8 changes: 4 additions & 4 deletions phoenixdb/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def close(self):
if self._closed:
raise ProgrammingError('the cursor is already closed')
if self._id is not None:
self._connection._client.closeStatement(self._connection._id, self._id)
self._connection._client.close_statement(self._connection._id, self._id)
self._id = None
self._signature = None
self._column_data_types = []
Expand Down Expand Up @@ -124,7 +124,7 @@ def description(self):

def _set_id(self, id):
if self._id is not None and self._id != id:
self._connection._client.closeStatement(self._connection._id, self._id)
self._connection._client.close_statement(self._connection._id, self._id)
self._id = id

def _set_signature(self, signature):
Expand Down Expand Up @@ -196,8 +196,8 @@ def execute(self, operation, parameters=None):
self._set_frame(None)
if parameters is None:
if self._id is None:
self._set_id(self._connection._client.createStatement(self._connection._id))
results = self._connection._client.prepareAndExecute(self._connection._id, self._id,
self._set_id(self._connection._client.create_statement(self._connection._id))
results = self._connection._client.prepare_and_execute(self._connection._id, self._id,
operation, first_frame_max_size=self.itersize)
self._process_results(results)
else:
Expand Down

0 comments on commit 54a9ba4

Please sign in to comment.