Python API Reference Guide

The Python API Reference Guide describes the following:


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:




Sets the SQream hostname or IP.


Sets the SQream port.


Sets the database name.


Sets the username for establishing a connection.


Sets the password used with your username.


Connects using either the load balancer or direct to worker (Default: false - direct to worker).


Uses an SSL connection (default: false).


(Optional) Sets the service queue (default: ‘sqream’).


Sets the number of failed reconnection attempts to attempt before closing the connection.


Sets the time in seconds between reconnection attempts.

Connection Object Parameters

The following table describes the Connection class parameters:




Specifies the number of rows to fetch at a time using fetchmany(). Default - 1.


Not used. Return -1.


Displays read-only attributes containing the following result set metadata:

  • name - Displays the column name.

  • type_code - Displays the internal type code.

  • display_size - Not used, identical to internal_size below.

  • internal_size - Displays the Data size (bytes).

  • precision - Not used. Displays the precision of numeric data.

  • scale - Not used. Displays the scale for numeric data.

  • null_ok - Specifices whether NULL values are allowed for the column.


Executes statements (self, query, params=None). Parameters are not supported.


Prepares a statement and executes it against all parameter sequences found in rows_or_cols (self, query, rows_or_cols=None, data_as=’rows’, amount=None).

  • self - Connection Object Parameters.

  • query - INSERT statement.

  • rows_or_cols - Data buffer to insert. This should be a sequence of lists or tuples..

  • data_as - (Optional) Read data as rows or columns.

  • amount - (Optional) count of rows to insert.


Closes a statement and connection (self). Closed statements must be reopened by creating a new cursor.


Creates a new Connection Object Parameters cursor (self). Recommended - create a new cursor for every statement.


Fetches all remaining records from the result set (self, data_as=’rows’). Returns an empty sequence if no more rows are available.


Fetches one record from the result set. Returns an empty sequence if no more rows are available.

  • self - Connection Object Parameters.

  • size - Sets the number of records to fetch. If not set, fetches Connection.arraysize records (default = 1).

  • data_as - (Optional) Reads data as rows or columns.


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 (?).