Sqlalchemy adapter for Firebolt
Project description
firebolt-sqlalchemy
This is the 'alpha' package. Expect updates in the future.
Firebolt is a Cloud Data Warehousing solution that helps its users streamline their Data Analytics and access to insights. It offers fast query performance and combines Elasticity, Simplicity, Low cost of the Cloud, and innovation in Analytics.
The SQLAlchemy Adapter will act as an interface for third-party applications with SQLAlchemy support (like Superset, Redash etc.) to communicate with Firebolt databases through REST APIs provided by Firebolt. The adapter is written in Python language using SQLAlchemy toolkit. It is built as per PEP 249 - Python Database API Specification v2.0 which specifies a set of standard interfaces for applications that wish to access a specific database.
Goals:
- Build Firebolt SQLAlchemy Adapter Python library: The aim is to package the Firebolt SQLAlchemy Adapter in a Python library which can be imported and used by third party applications.
- SQLAlchemy Adapter connects with Firebolt Database: The adapter should be able to access Firebolt database to retrieve database metadata and table data.
- Provide accessible methods for third party applications: The adapter should provide standard methods for third party applications to be able to use it as per its requirement.
Technologies:
- Python 3.*
- SQLAlchemy 1.4/2.0
- REST API
- Git and Github
- SQL
Installation:
pip install firebolt-sqlalchemy
Connection Method:
The recommended connection string is:
firebolt://{username}:{password}@{host}/{database}
Here's a connection string example of Superset connecting to a Firebolt database:
firebolt://email@domain:password@host/sample_database
DB API
from firebolt_db.firebolt_connector import connect
connection = connect('localhost',8123,'email@domain', 'password', 'db_name')
query = 'select * from sample_table limit 10'
cursor = connection.cursor()
response = cursor.execute(query)
print(response.fetchmany(3))
SQLAlchemy
from sqlalchemy import create_engine
from firebolt_db.firebolt_dialect import FireboltDialect
from sqlalchemy.dialects import registry
registry.register("firebolt", "src.firebolt_db.firebolt_dialect", "FireboltDialect")
engine = create_engine("firebolt://email@domain:password@host/sample_database")
dialect = FireboltDialect()
schemas = dialect.get_schema_names(engine)
connection = engine.connect()
schemas = dialect.get_schema_names(connection)
Components in the Adapter:
- Firebolt Connector: This file is used to establish a connection to the Firebolt database from 3rd party applications. It provides a ‘connect’ method which accepts parameters like database name, username, password etc. from the connecting application to identify the database and authenticate the user credentials. It returns a database connection which is used to execute queries on the database.
- API Service: The API Service is responsible for calling Firebolt REST APIs to establish connection with the database and fire SQL queries on it. It provides methods to get access token as per user credentials, get the specific engine URL and execute/run SQL queries. Executing queries need access token and engine URL as per the Firebolt REST API specifications.
- Firebolt Dialect: It provides methods for retrieving metadata about databases like schema data, table names, column names etc. It also maps the data types between Firebolt and SQLAlchemy along with providing a data type compiler for complex data types.
Testing Strategy:
- Test firebolt database creation, data ingestion and select query using Firebolt manager.
- Test getting access token and engine URL using Firebolt REST API through adapter API Service code.
- Test running SQL queries on a database using Firebolt REST API through adapter API service code.
- Test Firebolt Connector methods to create connection, get database cursor and execute SQL queries.
- Integration testing with Superset and Redash.
- End to end functionality testing through Superset and Redash.
- Link for unit tests: Unit-Testing Results
- Link for Query testing: Query-Testing Results
References:
- PyPi - Firebolt PyPi
- Important Firebolt URLs:
- SQLAlchemy: Dialect
- DB-API Driver: PEP 249
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.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2812576ef413527454ba0e2fd950facbd7bf4a6c7a19ddac3d7b3fa1eab1479 |
|
MD5 | c42caf2274d171216eb5bb3c7bee08a8 |
|
BLAKE2b-256 | b90fbc0a675a2a7101fa285dc8b750f64fad5d53ddcaa385d12d72668de48694 |
Hashes for firebolt_sqlalchemy-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b0766cf7662c27f0625aed4fd121b9a63eed698be5856b0e86e289523598d3b |
|
MD5 | 0f8b5c5452d504ccdb3ceff87912bc5a |
|
BLAKE2b-256 | e4a1d731b828305a920ad535a81b989a2fd01d18e9d3bd25937122d3341ca1e7 |