# SQLAlchemy [Theseus]((https://voltrondata.com/theseus.html)) Dialect - powered by Arrow Flight SQL ADBC
[<img src="https://img.shields.io/badge/GitHub-prmoore77%2Fsqlalchemy--theseus--dialect-blue.svg?logo=Github">](https://github.com/prmoore77/sqlalchemy-theseus-dialect)
[![sqlalchemy-theseus-dialect-ci](https://github.com/prmoore77/sqlalchemy-theseus-dialect/actions/workflows/ci.yml/badge.svg)](https://github.com/prmoore77/sqlalchemy-theseus-dialect/actions/workflows/ci.yml)
[![Supported Python Versions](https://img.shields.io/pypi/pyversions/sqlalchemy--theseus--dialect)](https://pypi.org/project/sqlalchemy-theseus-dialect/)
[![PyPI version](https://badge.fury.io/py/sqlalchemy-theseus-dialect.svg)](https://badge.fury.io/py/sqlalchemy-theseus-dialect)
[![PyPI Downloads](https://img.shields.io/pypi/dm/sqlalchemy--flight--sql--adbc--dialect.svg)](https://pypi.org/project/sqlalchemy-theseus-dialect/)
Basic SQLAlchemy dialect for [the Theseus Data Processing Engine](https://voltrondata.com/theseus.html)
## Installation
### Option 1 - from PyPi
```sh
$ pip install sqlalchemy-theseus-dialect
```
### Option 2 - from source - for development
```shell
git clone https://github.com/prmoore77/sqlalchemy-theseus-dialect
cd sqlalchemy-theseus-dialect
# Create the virtual environment
python3 -m venv .venv
# Activate the virtual environment
. .venv/bin/activate
# Upgrade pip, setuptools, and wheel
pip install --upgrade pip setuptools wheel
# Install SQLAlchemy Theseus Dialect - in editable mode with dev dependencies
pip install --editable .[dev]
```
### Note
For the following commands - if you running from source and using `--editable` mode (for development purposes) - you will need to set the PYTHONPATH environment variable as follows:
```shell
export PYTHONPATH=$(pwd)/src
```
## Usage
Once you've installed this package, you should be able to just use it, as SQLAlchemy does a python path search
### Ensure you have access to a Theseus engine
### Connect with the SQLAlchemy Theseus Dialect
```python
import logging
from sqlalchemy import create_engine, MetaData, Table, select, Column, text, Integer, String, Sequence
from sqlalchemy.orm import Session
from sqlalchemy.engine.url import URL
# Setup logging
logging.basicConfig()
logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
def main():
# Build the URL
url = URL.create(drivername="theseus",
host="theseus-gateway.vice.svc.cluster.local",
port=11234,
query={"disableCertificateVerification": "True",
"useEncryption": "False"
}
)
print(f"Database URL: {url}")
engine = create_engine(url=url)
metadata = MetaData()
metadata.reflect(bind=engine)
for table_name in metadata.tables:
print(f"Table name: {table_name}")
with Session(bind=engine) as session:
# Execute some raw SQL (this assumes you have a registered table called: "fake")
results = session.execute(statement=text("SELECT * FROM fake")).fetchall()
print(results)
# Try a SQLAlchemy table select
fake: Table = metadata.tables["fake"]
stmt = select(fake.c.name)
results = session.execute(statement=stmt).fetchall()
print(results)
if __name__ == "__main__":
main()
```
### Credits
Much code and inspiration was taken from repo: https://github.com/Mause/duckdb_engine
Raw data
{
"_id": null,
"home_page": null,
"name": "tester-dialect",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "sqlalchemy, theseus, gpu, flight-sql, adbc, dialect",
"author": null,
"author_email": "Philip Moore <prmoore77@hotmail.com>",
"download_url": "https://files.pythonhosted.org/packages/95/1f/332637751adca47b11d1958772185ae9759bd3acdb9ae4b368034f266db8/tester_dialect-0.0.10.tar.gz",
"platform": null,
"description": "# SQLAlchemy [Theseus]((https://voltrondata.com/theseus.html)) Dialect - powered by Arrow Flight SQL ADBC \n\n[<img src=\"https://img.shields.io/badge/GitHub-prmoore77%2Fsqlalchemy--theseus--dialect-blue.svg?logo=Github\">](https://github.com/prmoore77/sqlalchemy-theseus-dialect)\n[![sqlalchemy-theseus-dialect-ci](https://github.com/prmoore77/sqlalchemy-theseus-dialect/actions/workflows/ci.yml/badge.svg)](https://github.com/prmoore77/sqlalchemy-theseus-dialect/actions/workflows/ci.yml)\n[![Supported Python Versions](https://img.shields.io/pypi/pyversions/sqlalchemy--theseus--dialect)](https://pypi.org/project/sqlalchemy-theseus-dialect/)\n[![PyPI version](https://badge.fury.io/py/sqlalchemy-theseus-dialect.svg)](https://badge.fury.io/py/sqlalchemy-theseus-dialect)\n[![PyPI Downloads](https://img.shields.io/pypi/dm/sqlalchemy--flight--sql--adbc--dialect.svg)](https://pypi.org/project/sqlalchemy-theseus-dialect/)\n\nBasic SQLAlchemy dialect for [the Theseus Data Processing Engine](https://voltrondata.com/theseus.html)\n\n## Installation\n\n### Option 1 - from PyPi\n```sh\n$ pip install sqlalchemy-theseus-dialect\n```\n\n### Option 2 - from source - for development\n```shell\ngit clone https://github.com/prmoore77/sqlalchemy-theseus-dialect\n\ncd sqlalchemy-theseus-dialect\n\n# Create the virtual environment\npython3 -m venv .venv\n\n# Activate the virtual environment\n. .venv/bin/activate\n\n# Upgrade pip, setuptools, and wheel\npip install --upgrade pip setuptools wheel\n\n# Install SQLAlchemy Theseus Dialect - in editable mode with dev dependencies\npip install --editable .[dev]\n```\n\n### Note\nFor the following commands - if you running from source and using `--editable` mode (for development purposes) - you will need to set the PYTHONPATH environment variable as follows:\n```shell\nexport PYTHONPATH=$(pwd)/src\n```\n\n## Usage\n\nOnce you've installed this package, you should be able to just use it, as SQLAlchemy does a python path search\n\n### Ensure you have access to a Theseus engine\n\n### Connect with the SQLAlchemy Theseus Dialect\n```python\nimport logging\n\nfrom sqlalchemy import create_engine, MetaData, Table, select, Column, text, Integer, String, Sequence\nfrom sqlalchemy.orm import Session\nfrom sqlalchemy.engine.url import URL\n\n# Setup logging\nlogging.basicConfig()\nlogging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)\n\n\ndef main():\n # Build the URL\n url = URL.create(drivername=\"theseus\",\n host=\"theseus-gateway.vice.svc.cluster.local\",\n port=11234,\n query={\"disableCertificateVerification\": \"True\",\n \"useEncryption\": \"False\"\n }\n )\n\n print(f\"Database URL: {url}\")\n\n engine = create_engine(url=url)\n\n metadata = MetaData()\n metadata.reflect(bind=engine)\n\n for table_name in metadata.tables:\n print(f\"Table name: {table_name}\")\n\n with Session(bind=engine) as session:\n\n # Execute some raw SQL (this assumes you have a registered table called: \"fake\")\n results = session.execute(statement=text(\"SELECT * FROM fake\")).fetchall()\n print(results)\n\n # Try a SQLAlchemy table select\n fake: Table = metadata.tables[\"fake\"]\n stmt = select(fake.c.name)\n\n results = session.execute(statement=stmt).fetchall()\n print(results)\n\n\nif __name__ == \"__main__\":\n main()\n```\n\n### Credits\nMuch code and inspiration was taken from repo: https://github.com/Mause/duckdb_engine\n",
"bugtrack_url": null,
"license": null,
"summary": "A SQLAlchemy dialect for connecting to a Theseus Flight SQL server with ADBC",
"version": "0.0.10",
"project_urls": {
"Homepage": "https://github.com/prmoore77/sqlalchemy-theseus-dialect"
},
"split_keywords": [
"sqlalchemy",
" theseus",
" gpu",
" flight-sql",
" adbc",
" dialect"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3b3e75eb3a051320d82878cfd0e6c3f0aa1b8401884a36cb7a5367f5ce443a9f",
"md5": "c559092db47278d910d93321904d734a",
"sha256": "058dc945c3487153d7faa5acbb94d2f2b3c35e49efcaf067e61cd7975b0fe85e"
},
"downloads": -1,
"filename": "tester_dialect-0.0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c559092db47278d910d93321904d734a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 9302,
"upload_time": "2024-07-16T21:10:47",
"upload_time_iso_8601": "2024-07-16T21:10:47.884517Z",
"url": "https://files.pythonhosted.org/packages/3b/3e/75eb3a051320d82878cfd0e6c3f0aa1b8401884a36cb7a5367f5ce443a9f/tester_dialect-0.0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "951f332637751adca47b11d1958772185ae9759bd3acdb9ae4b368034f266db8",
"md5": "8149479a15a4d0f8d8dbbba38fdf544e",
"sha256": "bcd156decfed0d801cc5bc640bc3fb85310dd284ff0b846b7bc6092f99e594c4"
},
"downloads": -1,
"filename": "tester_dialect-0.0.10.tar.gz",
"has_sig": false,
"md5_digest": "8149479a15a4d0f8d8dbbba38fdf544e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 10467,
"upload_time": "2024-07-16T21:10:49",
"upload_time_iso_8601": "2024-07-16T21:10:49.861416Z",
"url": "https://files.pythonhosted.org/packages/95/1f/332637751adca47b11d1958772185ae9759bd3acdb9ae4b368034f266db8/tester_dialect-0.0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-16 21:10:49",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "prmoore77",
"github_project": "sqlalchemy-theseus-dialect",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tester-dialect"
}