Sqlalchemy adapter for Firebolt
Project description
firebolt-sqlalchemy
The Firebolt dialect for SQLAlchemy. firebolt-sqlalchemy
uses Firebolt's Python SDK which implements PEP 249.
Installation
Requires Python >=3.7.
pip install firebolt-sqlalchemy
Connecting
Connection strings use the following structure:
firebolt://{username}:{password}@{database}[/{engine_name}][?account_name={name}}]
engine_name
is optional. If omitted, Firebolt will use the default engine for the database.
account_name
is optional. If omitted a default account will be used for connection.
Examples:
firebolt://email@domain:password@sample_database
firebolt://email@domain:password@sample_database/sample_engine
If a different account name is required, it can be specified in the connection string
firebolt://email@domain:password@sample_database/sample_engine?account_name=my_account
To override the API URL (e.g. for dev testing):
export FIREBOLT_BASE_URL=<your_url>
If your password contains % or / characters they need to be sanitised as per https://docs.sqlalchemy.org/en/14/core/engines.html#database-urls
my_pass = "0920%/2"
import urllib.parse
new_pass = urllib.parse.quote_plus(my_pass)
Quick Start
import urllib.parse
from sqlalchemy import create_engine
password = urllib.parse.quote_plus("your_password_here")
engine = create_engine("firebolt://email@domain:" + password + "@sample_database/sample_engine")
connection = engine.connect()
connection.execute("CREATE FACT TABLE example(dummy int) PRIMARY INDEX dummy")
connection.execute("INSERT INTO example(dummy) VALUES (11)")
result = connection.execute("SELECT * FROM example")
for item in result.fetchall():
print(item)
AsyncIO extension
import urllib.parse
from sqlalchemy import text
from sqlalchemy.ext.asyncio import create_async_engine
password = urllib.parse.quote_plus("your_password_here")
engine = create_async_engine("asyncio+firebolt://email@domain:" + password + "@sample_database/sample_engine")
async with engine.connect() as conn:
await conn.execute(
text(f"INSERT INTO example(dummy) VALUES (11)")
)
result = await conn.execute(
text(f"SELECT * FROM example")
)
print(result.fetchall())
await engine.dispose()
Limitations
- Transactions are not supported since Firebolt database does not support them at this time.
- Parametrised calls to execute and executemany are not implemented.
Contributing
See: CONTRIBUTING.MD
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
Hashes for firebolt_sqlalchemy-0.9.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b7e6df55b1ffb9ba31e3b57b293ebc4680e923fe1438d084375926b1ce6c94d |
|
MD5 | 36cf14ff28ba614c23f9be6361e01b1e |
|
BLAKE2b-256 | 594514d38740995c31aa780da4f8ceec502ec29e4401099ede0f6fe2b2455ac2 |
Hashes for firebolt_sqlalchemy-0.9.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb02379faa4c69bf7508d068f9283baa7aa0b65baf762c8b26c0650d7ba1a185 |
|
MD5 | ba9316b6aed2827df0e20d27215a9658 |
|
BLAKE2b-256 | 41d8f646b53f2e1ed1b24e876c4a56e5d53160e3269ad89149d7cd6d2f9a6946 |