Skip to main content
  • Version: 1.0.41

  • Supported SQream DB versions: >= Blue cloud

The Python connector for SQream DB is a Python DB API 2.0-compliant interface for developing Python applications with SQream DB.

The SQream Python connector provides an interface for creating and running Python applications that can connect to a SQream DB database. It provides a lighter-weight alternative to working through native C++ or Java bindings, including JDBC and ODBC drivers.

pysqream conforms to Python DB-API specifications PEP-249

pysqream_blue is native and pure Python, with minimal requirements. It can be installed with pip3 on any operating system, including Linux, Windows, and macOS.

Requirements

  • Python 3.9+

Installing the Python connector

Prerequisites

1. Python

The connector requires Python 3.9 or newer. To verify your version of Python:

$ python --version
Python 3.9

2. PIP

The Python connector is installed via pip3, the Python package manager and installer.

We recommend upgrading to the latest version of pip3 before installing. To verify that you are on the latest version, run the following command:

$ python -m pip3 install --upgrade pip
Collecting pip
   Downloading https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl (1.4MB)
     |████████████████████████████████| 1.4MB 1.6MB/s
Installing collected packages: pip
  Found existing installation: pip 19.1.1
    Uninstalling pip-19.1.1:
      Successfully uninstalled pip-19.1.1
Successfully installed pip-19.3.1

Install via pip

The Python connector is available via PyPi.

Install the connector with pip3:

$ pip3 install pysqream-blue

pip3 will automatically installs all necessary libraries and modules.

Validate the installation

Create a file called test.py (make sure to replace the parameters in the connection with the respective parameters for your SQream DB installation):

#!/usr/bin/env python

import pysqream_blue

"""
Connection parameters include:
* IP/Hostname
* Port
* database name
* username
* password
* Connect through load balancer, or direct to worker (Default: false - direct to worker)
* use SSL connection (default: false)
* Optional service queue (default: 'sqream')
"""

# Create a connection object

con = pysqream_blue.connect(host='127.0.0.1', port='80',
                            database='master', username='sqream', password='sqream')

# Create a new cursor
cur = con.cursor()

# Prepare and execute a query
cur.execute('select 1')

result = cur.fetchall() # `fetchall` gets the entire data set

print(f"Result: {result}")

# This should print the SQream DB version. For example ``Version: v2020.1``.

# close statement
cur.close()

# Finally, close the connection
con.close()

Logging

To enable logging, pass a path to a log file in the connection string as follows:

pysqream_blue.set_log_path('PATH LOG FILE')
con = pysqream_blue.connect('127.0.0.1', '80', use_logs=True, log_level='INFO')

For example save to ‘/tmp/sqream_dbapi.log’:

pysqream_blue.set_log_path('/tmp/sqream_dbapi.log')
con = pysqream_blue.connect('127.0.0.1', '80', use_logs=True, log_level='INFO')

The log level default is ‘INFO’, the logs level are [‘INFO’, ‘DEBUG’, ‘CRITICAL’, ‘WARNING’, ‘ERROR’]

TODO (when server support):

  • use ssl connection.

  • send the token recived in authentication in every following request as call credentials (compile, execute, etc).

  • parametered queries / network insert. the existing code related to those points is a preparation and not reliable.

Differences from V1 pysqream (from user view):

  • The parameters to connect function are different (some were removed and some were added).

  • SSL connection not supported.

  • executemany() (- network insert) not supported.

Design decisions:

  • The grpc chunnel and stubs are opened and closed by __init__ and __del__ methods (which call _connect_to_server() and _disconnect_server() where the implementation itself is). The authentication with sqream and receipt a token made by connect_database() method (while close() close it). User can call close() and then connect_database() for swiching between databases on the same server. It may make sense to decide to close the chunnel as well in close() method (which is a part of DB API).

  • The same chunnel and stubs used for all cursors of a connection but every cursor open his own token. it may make sense to decide to use different stubs or chunnel for every cursor or to use the same token for all.

  • Fetch methods return list of list and not list of tuple

License-File: LICENSE

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysqream-blue-1.0.41.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysqream_blue-1.0.41-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file pysqream-blue-1.0.41.tar.gz.

File metadata

  • Download URL: pysqream-blue-1.0.41.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pysqream-blue-1.0.41.tar.gz
Algorithm Hash digest
SHA256 b9528064fe21754fb598e183ae2f48d6fb4e928ac557bb09f96a92a453f9b77b
MD5 6d956718c40d2edac46a84faa0ba0548
BLAKE2b-256 12fcc671fa24ded4b8f0805be55f899196873331c088fd77dde62e65d9a9b8da

See more details on using hashes here.

File details

Details for the file pysqream_blue-1.0.41-py3-none-any.whl.

File metadata

  • Download URL: pysqream_blue-1.0.41-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pysqream_blue-1.0.41-py3-none-any.whl
Algorithm Hash digest
SHA256 a9357ca38f8c47e3ffc5f56368f7368cbecc69823712d67f851a17758170e75d
MD5 5f7d42e7183f2134e11de7a8dfbe5dd5
BLAKE2b-256 8cdd4b8cb7e8eb97ae3faed79e222a7aaa29aaa2b0887c7835e934736b3c8b02

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page