EXASOL dialect for SQLAlchemy
Project description
Getting Started with SQLAlchemy-Exasol
SQLAlchemy-Exasol supports multiple dialects, primarily differentiated by whether they are ODBC or Websocket based.
Choosing a Dialect
We recommend using the Websocket-based dialect due to its simplicity. ODBC-based dialects demand a thorough understanding of (Unix)ODBC, and the setup is considerably more complex.
System Requirements
Python
An Exasol DB (e.g. docker-db or a cloud instance)
Setting Up Your Python Project
Install SQLAlchemy-Exasol:
$ pip install sqlalchemy-exasol
Using SQLAlchemy with EXASOL DB
Websocket based Dialect:
from sqlalchemy import create_engine
url = "exa+websocket://A_USER:A_PASSWORD@192.168.1.2..8:1234/my_schema?CONNECTIONLCALL=en_US.UTF-8"
e = create_engine(url)
r = e.execute("select 42 from dual").fetchall()
Examples:
from sqlalchemy import create_engine
engine = create_engine("exa+websocket://sys:exasol@127.0.0.1:8888")
with engine.connect() as con:
...
from sqlalchemy import create_engine
# ATTENTION:
# In terms of security it is NEVER a good idea to turn of certificate validation!!
# In rare cases it may be handy for non-security related reasons.
# That said, if you are not a 100% sure about your scenario, stick with the
# secure defaults.
# In most cases, having a valid certificate and/or configuring the truststore(s)
# appropriately is the best/correct solution.
engine = create_engine("exa+websocket://sys:exasol@127.0.0.1:8888?SSLCertificate=SSL_VERIFY_NONE")
with engine.connect() as con:
...
Pyodbc (ODBC based Dialect):
from sqlalchemy import create_engine
url = "exa+pyodbc://A_USER:A_PASSWORD@192.168.1.2..8:1234/my_schema?CONNECTIONLCALL=en_US.UTF-8&driver=EXAODBC"
e = create_engine(url)
r = e.execute("select 42 from dual").fetchall()
Turbodbc (ODBC based Dialect):
from sqlalchemy import create_engine
url = "exa+turbodbc://A_USER:A_PASSWORD@192.168.1.2..8:1234/my_schema?CONNECTIONLCALL=en_US.UTF-8&driver=EXAODBC"
e = create_engine(url)
r = e.execute("select 42 from dual").fetchall()
Features
SELECT, INSERT, UPDATE, DELETE statements
General Notes
Schema name and parameters are optional for the host url
At least on Linux/Unix systems it has proven valuable to pass ‘CONNECTIONLCALL=en_US.UTF-8’ as a url parameter. This will make sure that the client process (Python) and the EXASOL driver (UTF-8 internal) know how to interpret code pages correctly.
Always use all lower-case identifiers for schema, table and column names. SQLAlchemy treats all lower-case identifiers as case-insensitive, the dialect takes care of transforming the identifier into a case-insensitive representation of the specific database (in case of EXASol this is upper-case as for Oracle)
As of Exasol client driver version 4.1.2 you can pass the flag ‘INTTYPESINRESULTSIFPOSSIBLE=y’ in the connection string (or configure it in your DSN). This will convert DECIMAL data types to Integer-like data types. Creating integers is a factor three faster in Python than creating Decimals.
Known Issues
- Insert
Insert multiple empty rows via prepared statements does not work in all cases
Development & Testing
See developer guide
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sqlalchemy_exasol-5.0.0.tar.gz
.
File metadata
- Download URL: sqlalchemy_exasol-5.0.0.tar.gz
- Upload date:
- Size: 37.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.8.18 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 901ff0a7990238c25791f6b9116b6b999661c2ecc16f59245d51358ee8b7bc12 |
|
MD5 | 10b52e208b46af07f2e11631fbcd303e |
|
BLAKE2b-256 | 47e24b4c592f8269cbc572197721188e30376f8df17cc8f9ff53a00802ebdcc4 |
File details
Details for the file sqlalchemy_exasol-5.0.0-py3-none-any.whl
.
File metadata
- Download URL: sqlalchemy_exasol-5.0.0-py3-none-any.whl
- Upload date:
- Size: 46.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.8.18 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60345d8e0a0f7d68977376b59892142aa99149d635e3f044926ed12942c41060 |
|
MD5 | 9617375c967cbff8668e7d1caf64d159 |
|
BLAKE2b-256 | aa3d9a443f967cadac4398c5947b064685a1813a3f94ad5d64312d7ce55678f3 |