Skip to main content

Python connector for SQream DB Blue

  • Version: 1.0.16

  • 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 pip on any operating system, including Linux, Windows, and macOS.

Requirements

  • Python 3.6.5+, with 3.7+ highly recommended

Installing the Python connector

Prerequisites

1. Python

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

$ python --version
Python 3.7.3

Note: If both Python 2.x and 3.x are installed, you can run python3 and pip3 instead of python and pip respectively for the rest of this guide

2. PIP

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

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

$ python -m pip 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 pip:

$ pip install pysqream-blue

pip 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:

con = pysqream_blue.connect('127.0.0.1', '80', log = '/path/to/logfile.xx')

Or pass True to save to ‘/tmp/sqream_dbapi.log’:

con = pysqream_blue.connect('127.0.0.1', '80', log =True)

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

UNKNOWN

Metadata

Release files for pysqream-blue 1.0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysqream-blue 1.0.16
File Size Uploaded
pysqream-blue-1.0.16.tar.gz 21.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pysqream-blue 1.0.16
File Interpreter ABI Platform
pysqream_blue-1.0.16-py3-none-any.whl Python 3 none any Details

Total release size: 45.1 kB

Release files / pysqream-blue-1.0.16.tar.gz

Download URL pysqream-blue-1.0.16.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f01c3de54eb95500a452072d467320d7f489c7725547e237ad9077bb58237e4c
BLAKE2b-256 checksum
How to use checksums
a27073730ecb5d50fd27d3ec7747a85926c0b4b0379445ac8b50f0bf62a0f059
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.0 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

Release files / pysqream_blue-1.0.16-py3-none-any.whl

Download URL pysqream_blue-1.0.16-py3-none-any.whl
Size 23.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47a28a1749ac23ec8afaa993d4ea3242dfc4f469d5748b34387d6c732d1a12fc
BLAKE2b-256 checksum
How to use checksums
17d68088e1e02c2b5653e8f4edda7e41d6661bdc9e217c18a79516ca43915018
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.0 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page