Package: pysqream-blue
Version:1.0.43Supported SQream DB versions:>= Blue cloudThe 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 specificationsPEP-249pysqream_blueis native and pure Python, with minimal requirements. It can be installed withpip3on any operating system, including Linux, Windows, and macOS.RequirementsPython 3.9+Installing the Python connectorPrerequisites1. PythonThe connector requires Python 3.9 or newer. To verify your version of Python:$python--versionPython 3.92. PIPThe Python connector is installed viapip3, the Python package manager and installer.We recommend upgrading to the latest version ofpip3before installing. To verify that you are on the latest version, run the following command:$python-mpip3install--upgradepipCollecting 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.1NoteOn macOS, you may want to use virtualenv to install Python and the connector, to ensure compatibility with the built-in Python environmentIf you encounter an error includingSSLErrororWARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.- please be sure to reinstall Python with SSL enabled, or use virtualenv or Anaconda.Install via pipThe Python connector is available viaPyPi.Install the connector withpip3:$pip3installpysqream-bluepip3will automatically installs all necessary libraries and modules.Validate the installationCreate a file calledtest.py(make sure to replace the parameters in the connection with the respective parameters for your SQream DB installation):#!/usr/bin/env pythonimportpysqream_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 objectcon=pysqream_blue.connect(host='127.0.0.1',port='80',database='master',username='sqream',password='sqream')# Create a new cursorcur=con.cursor()# Prepare and execute a querycur.execute('select 1')result=cur.fetchall()# `fetchall` gets the entire data setprint(f"Result:{result}")# This should print the SQream DB version. For example ``Version: v2020.1``.# close statementcur.close()# Finally, close the connectioncon.close()LoggingTo 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 byconnect_database()method (whileclose()close it).
User can callclose()and thenconnect_database()for swiching between databases on the same server.
It may make sense to decide to close the chunnel as well inclose()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 tupleLicense-File: LICENSE