Python API Reference Guide
The Python API Reference Guide describes the following:
Overview
The SQream Python connector allows Python programs to connect to SQream, and conforms to Python DB-API specifications PEP-249. The main Python connector module is pysqream, which contains the connection
class.
The following is the syntax for the connect
class:
$ connect(host, port, database, username, password, clustered = False, use_ssl = False, service='sqream', reconnect_attempts=3, reconnect_interval=10)
The Connection
class creates a new Connection
object and connects to SQream.
The following table describes the connect
object parameters:
Parameter |
Description |
---|---|
host |
Sets the SQream hostname or IP. |
port |
Sets the SQream port. |
database |
Sets the database name. |
username |
Sets the username for establishing a connection. |
password |
Sets the password used with your |
clustered |
Connects using either the load balancer or direct to worker (Default: false - direct to worker). |
use_ssl |
Uses an SSL connection (default: false). |
service |
(Optional) Sets the service queue (default: ‘sqream’). |
reconnect_attempts |
Sets the number of failed reconnection attempts to attempt before closing the connection. |
reconnect_interval |
Sets the time in seconds between reconnection attempts. |
Connection Object Parameters
The following table describes the Connection
class parameters:
Parameter |
Description |
---|---|
arraysize |
Specifies the number of rows to fetch at a time using |
rowcount |
Not used. Return |
description |
Displays read-only attributes containing the following result set metadata:
|
execute |
Executes statements (self, query, params=None). Parameters are not supported.
|
executemany |
Prepares a statement and executes it against all parameter sequences found in
|
close |
Closes a statement and connection (self). Closed statements must be reopened by creating a new cursor.
|
cursor |
Creates a new Connection Object Parameters cursor (self). Recommended - create a new cursor for every statement.
|
fetchall |
Fetches all remaining records from the result set (self, data_as=’rows’). Returns an empty sequence if no more rows are available.
|
fetchone |
Fetches one record from the result set. Returns an empty sequence if no more rows are available.
|
__iter__() |
Makes the cursor iterable. |
API Level Object Parameters
The API Level object parameter is a string constant stating the supported API level. The Python connector supports apilevel
2.0.
Thread Safety Object Parameters
The Thread Safety object parameter displays the thread safety level the interface supports. The Python connector currently supports threadsafety
level 1, which states that threads can share the module, but not connections.
Parameter Style Object Parameters
The paramstyle object parameter sets the placeholder marker and is set to to qmark
, which is a question mark (?
).