<p align="center">
<img width="761" alt="SQLAlchemy and Firebolt" src="https://user-images.githubusercontent.com/7674553/145249436-534b3cc0-2350-4f7e-9c56-78ffbcc0f003.png">
</p>
# firebolt-sqlalchemy
[](https://github.com/firebolt-db/firebolt-sqlalchemy/actions/workflows/unit-tests.yml)
[](https://github.com/firebolt-db/firebolt-sqlalchemy/actions/workflows/code-check.yml)
[](https://github.com/firebolt-db/firebolt-sqlalchemy/actions/workflows/security-scan.yml)
[](https://github.com/firebolt-db/firebolt-sqlalchemy/actions/workflows/python-integration-tests.yml)

The [Firebolt](https://www.firebolt.io/) dialect for [SQLAlchemy](https://www.sqlalchemy.org/). `firebolt-sqlalchemy` uses [Firebolt's Python SDK](https://github.com/firebolt-db/firebolt-python-sdk) which implements [PEP 249](https://www.python.org/dev/peps/pep-0249/).
* [SQLAlchemy Dialects](https://docs.sqlalchemy.org/en/20/dialects/index.html#external-dialects)
* [PyPI Package](https://pypi.org/project/firebolt-sqlalchemy/)
## Installation
Requires Python >=3.7.
```bash
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):
```bash
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
```python
my_secret = "0920%/2"
import urllib.parse
new_secret = urllib.parse.quote_plus(my_secret)
```
## Quick Start
```python
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](https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html) extension
```python
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.
1. Parametrised calls to execute and executemany are not implemented.
## Contributing
See: [CONTRIBUTING.MD](https://github.com/firebolt-db/firebolt-sqlalchemy/tree/master/CONTRIBUTING.MD)
Raw data
{
"_id": null,
"home_page": "https://github.com/firebolt-db/firebolt-sqlalchemy",
"name": "firebolt-sqlalchemy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Firebolt",
"author_email": "pypi@firebolt.io",
"download_url": "https://files.pythonhosted.org/packages/f0/22/8fc793a7ffa2de5dcde11d0405039954e5675aa2a9b800ce82143f23b738/firebolt_sqlalchemy-1.0.3.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <img width=\"761\" alt=\"SQLAlchemy and Firebolt\" src=\"https://user-images.githubusercontent.com/7674553/145249436-534b3cc0-2350-4f7e-9c56-78ffbcc0f003.png\">\n</p>\n\n# firebolt-sqlalchemy\n\n[](https://github.com/firebolt-db/firebolt-sqlalchemy/actions/workflows/unit-tests.yml)\n[](https://github.com/firebolt-db/firebolt-sqlalchemy/actions/workflows/code-check.yml)\n[](https://github.com/firebolt-db/firebolt-sqlalchemy/actions/workflows/security-scan.yml)\n[](https://github.com/firebolt-db/firebolt-sqlalchemy/actions/workflows/python-integration-tests.yml)\n\n\n\n\nThe [Firebolt](https://www.firebolt.io/) dialect for [SQLAlchemy](https://www.sqlalchemy.org/). `firebolt-sqlalchemy` uses [Firebolt's Python SDK](https://github.com/firebolt-db/firebolt-python-sdk) which implements [PEP 249](https://www.python.org/dev/peps/pep-0249/).\n\n* [SQLAlchemy Dialects](https://docs.sqlalchemy.org/en/20/dialects/index.html#external-dialects)\n* [PyPI Package](https://pypi.org/project/firebolt-sqlalchemy/)\n\n## Installation\n\nRequires Python >=3.7.\n\n```bash\npip install firebolt-sqlalchemy\n```\n\n## Connecting\n\nConnection strings use the following structure:\n\n```\nfirebolt://{client_id}:{client_secret}@{database}[/{engine_name}]?account_name={name}\n```\n\n`engine_name` is optional.\n\n`account_name` is required.\n\nExamples:\n\n```\nfirebolt://aaa-bbb-ccc-222:$ecret@sample_database?account_name=my_account\nfirebolt://aaa-bbb-ccc-222:$ecret@sample_database/sample_engine?account_name=my_account\n```\n\nTo override the API URL (e.g. for dev testing):\n\n```bash\nexport FIREBOLT_BASE_URL=<your_url>\n```\n\nIf your secret contains % or / characters they need to be sanitised as per https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls\n```python\nmy_secret = \"0920%/2\"\nimport urllib.parse\nnew_secret = urllib.parse.quote_plus(my_secret)\n```\n\n## Quick Start\n\n```python\nimport urllib.parse\nfrom sqlalchemy import create_engine\n\nsecret = urllib.parse.quote_plus(\"your_secret_here\")\nengine = create_engine(\"firebolt://aaa-bbb-ccc-222:\" + secret + \"@sample_database/sample_engine?account_name=my_account\")\nconnection = engine.connect()\n\nconnection.execute(\"CREATE FACT TABLE example(dummy int) PRIMARY INDEX dummy\")\nconnection.execute(\"INSERT INTO example(dummy) VALUES (11)\")\nresult = connection.execute(\"SELECT * FROM example\")\nfor item in result.fetchall():\n print(item)\n```\n\n### [AsyncIO](https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html) extension\n\n```python\nimport urllib.parse\nfrom sqlalchemy import text\nfrom sqlalchemy.ext.asyncio import create_async_engine\n\nsecret = urllib.parse.quote_plus(\"your_secret_here\")\nengine = create_async_engine(\"asyncio+firebolt://aaa-bbb-ccc-222:\" + secret + \"@sample_database/sample_engine?account_name=my_account\")\n\nasync with engine.connect() as conn:\n\n await conn.execute(\n text(f\"INSERT INTO example(dummy) VALUES (11)\")\n )\n\n result = await conn.execute(\n text(f\"SELECT * FROM example\")\n )\n print(result.fetchall())\n\nawait engine.dispose()\n```\n\n\n## Limitations\n\n1. Transactions are not supported since Firebolt database does not support them at this time.\n1. Parametrised calls to execute and executemany are not implemented.\n\n## Contributing\n\nSee: [CONTRIBUTING.MD](https://github.com/firebolt-db/firebolt-sqlalchemy/tree/master/CONTRIBUTING.MD)\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Sqlalchemy adapter for Firebolt",
"version": "1.0.3",
"project_urls": {
"Bug Tracker": "https://github.com/firebolt-db/firebolt-sqlalchemy",
"Download": "https://github.com/firebolt-db/firebolt-sqlalchemy/archive/refs/tags/0.0.9.tar.gz",
"Homepage": "https://github.com/firebolt-db/firebolt-sqlalchemy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "217f65899d418f8fc31395aef661a9e25209e76697e4f66e267dc0d9d665641a",
"md5": "884cea1a9663ec0738b18e4d30d211d8",
"sha256": "f293cf62ffb9a99c4e3d2a735c976503f1373d2b17a1784f2f9fa2b194ec0da0"
},
"downloads": -1,
"filename": "firebolt_sqlalchemy-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "884cea1a9663ec0738b18e4d30d211d8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 12500,
"upload_time": "2024-08-28T12:18:59",
"upload_time_iso_8601": "2024-08-28T12:18:59.817732Z",
"url": "https://files.pythonhosted.org/packages/21/7f/65899d418f8fc31395aef661a9e25209e76697e4f66e267dc0d9d665641a/firebolt_sqlalchemy-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f0228fc793a7ffa2de5dcde11d0405039954e5675aa2a9b800ce82143f23b738",
"md5": "373c8e0fc1bdbbe0a7a3efdc2691df4b",
"sha256": "76c7fb55c41d720f9c125467b307e044006be3e6ceaeea76fc52b90bf0e8640d"
},
"downloads": -1,
"filename": "firebolt_sqlalchemy-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "373c8e0fc1bdbbe0a7a3efdc2691df4b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 11720,
"upload_time": "2024-08-28T12:19:01",
"upload_time_iso_8601": "2024-08-28T12:19:01.589181Z",
"url": "https://files.pythonhosted.org/packages/f0/22/8fc793a7ffa2de5dcde11d0405039954e5675aa2a9b800ce82143f23b738/firebolt_sqlalchemy-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-28 12:19:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "firebolt-db",
"github_project": "firebolt-sqlalchemy",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "firebolt-sqlalchemy"
}