Skip to main content

Sqlalchemy adapter for Firebolt

Project description

SQLAlchemy and Firebolt

firebolt-sqlalchemy

Unit tests Code quality checks Firebolt Security Scan Integration tests Coverage

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://{client_id}:{client_secret}@{database}[/{engine_name}]?account_name={name}

engine_name is optional.

account_name is required.

Examples:

firebolt://aaa-bbb-ccc-222:$ecret@sample_database?account_name=my_account
firebolt://aaa-bbb-ccc-222:$ecret@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 secret contains % or / characters they need to be sanitised as per https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls

my_secret = "0920%/2"
import urllib.parse
new_secret = urllib.parse.quote_plus(my_secret)

Quick Start

import urllib.parse
from sqlalchemy import create_engine

secret = urllib.parse.quote_plus("your_secret_here")
engine = create_engine("firebolt://aaa-bbb-ccc-222:" + secret + "@sample_database/sample_engine?account_name=my_account")
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

secret = urllib.parse.quote_plus("your_secret_here")
engine = create_async_engine("asyncio+firebolt://aaa-bbb-ccc-222:" + secret + "@sample_database/sample_engine?account_name=my_account")

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

  1. Transactions are not supported since Firebolt database does not support them at this time.
  2. Parametrised calls to execute and executemany are not implemented.

Contributing

See: CONTRIBUTING.MD

Project details


Download files

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

Source Distribution

firebolt_sqlalchemy-1.0.3.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

firebolt_sqlalchemy-1.0.3-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file firebolt_sqlalchemy-1.0.3.tar.gz.

File metadata

  • Download URL: firebolt_sqlalchemy-1.0.3.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.17

File hashes

Hashes for firebolt_sqlalchemy-1.0.3.tar.gz
Algorithm Hash digest
SHA256 76c7fb55c41d720f9c125467b307e044006be3e6ceaeea76fc52b90bf0e8640d
MD5 373c8e0fc1bdbbe0a7a3efdc2691df4b
BLAKE2b-256 f0228fc793a7ffa2de5dcde11d0405039954e5675aa2a9b800ce82143f23b738

See more details on using hashes here.

File details

Details for the file firebolt_sqlalchemy-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for firebolt_sqlalchemy-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f293cf62ffb9a99c4e3d2a735c976503f1373d2b17a1784f2f9fa2b194ec0da0
MD5 884cea1a9663ec0738b18e4d30d211d8
BLAKE2b-256 217f65899d418f8fc31395aef661a9e25209e76697e4f66e267dc0d9d665641a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page