# YDB Dialect for SQLAlchemy
---
[](https://github.com/ydb-platform/ydb-sqlalchemy/blob/main/LICENSE)
[](https://github.com/ydb-platform/ydb-sqlalchemy/actions/workflows/tests.yml)
[](https://github.com/ydb-platform/ydb-sqlalchemy/actions/workflows/style.yml)
This repository contains YQL dialect for SqlAlchemy 2.0.
**Note**: Dialect also works with SqlAlchemy 1.4, but it is not fully tested.
## Installation
To work with current ydb-sqlalchemy version clone this repo and run from source root:
```bash
$ pip install -U .
```
## Getting started
Connect to local YDB using SqlAlchemy:
```python3
import sqlalchemy as sa
engine = sa.create_engine("yql+ydb://localhost:2136/local")
with engine.connect() as conn:
rs = conn.execute(sa.text("SELECT 1 AS value"))
print(rs.fetchone())
```
To setup `alembic` to work with `YDB` please check [this example](https://github.com/ydb-platform/ydb-sqlalchemy/tree/main/examples/alembic).
## Development
### Run Tests:
Run the command from the root directory of the repository to start YDB in a local docker container.
```bash
$ docker-compose up
```
To run all tests execute the command from the root directory of the repository:
```bash
$ tox -e test-all
```
Run specific test:
```bash
$ tox -e test -- test/test_core.py
```
Check code style:
```bash
$ tox -e style
```
Reformat code:
```bash
$ tox -e isort
$ tox -e black-format
```
Run example (needs running local YDB):
```bash
$ python -m pip install virtualenv
$ virtualenv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
$ python examples/example.py
```
Raw data
{
"_id": null,
"home_page": "http://github.com/ydb-platform/ydb-sqlalchemy",
"name": "ydb-sqlalchemy",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "SQLAlchemy YDB YQL",
"author": "Yandex LLC",
"author_email": "ydb@yandex-team.ru",
"download_url": "https://files.pythonhosted.org/packages/ce/84/9d4c9f5087ac71ed4f907463b191696604add44692aa8f64fd07bde0a89e/ydb_sqlalchemy-0.1.8.tar.gz",
"platform": null,
"description": "# YDB Dialect for SQLAlchemy\n---\n[](https://github.com/ydb-platform/ydb-sqlalchemy/blob/main/LICENSE)\n[](https://github.com/ydb-platform/ydb-sqlalchemy/actions/workflows/tests.yml)\n[](https://github.com/ydb-platform/ydb-sqlalchemy/actions/workflows/style.yml)\n\nThis repository contains YQL dialect for SqlAlchemy 2.0.\n\n**Note**: Dialect also works with SqlAlchemy 1.4, but it is not fully tested.\n\n\n## Installation\nTo work with current ydb-sqlalchemy version clone this repo and run from source root:\n\n```bash\n$ pip install -U .\n```\n\n## Getting started\n\nConnect to local YDB using SqlAlchemy:\n\n```python3\nimport sqlalchemy as sa\n\n\nengine = sa.create_engine(\"yql+ydb://localhost:2136/local\")\n\nwith engine.connect() as conn:\n rs = conn.execute(sa.text(\"SELECT 1 AS value\"))\n print(rs.fetchone())\n\n```\n\nTo setup `alembic` to work with `YDB` please check [this example](https://github.com/ydb-platform/ydb-sqlalchemy/tree/main/examples/alembic).\n\n## Development\n\n### Run Tests:\n\nRun the command from the root directory of the repository to start YDB in a local docker container.\n```bash\n$ docker-compose up\n```\n\nTo run all tests execute the command from the root directory of the repository:\n```bash\n$ tox -e test-all\n```\n\nRun specific test:\n```bash\n$ tox -e test -- test/test_core.py\n```\n\nCheck code style:\n```bash\n$ tox -e style\n```\n\nReformat code:\n```bash\n$ tox -e isort\n$ tox -e black-format\n```\n\nRun example (needs running local YDB):\n```bash\n$ python -m pip install virtualenv\n$ virtualenv venv\n$ source venv/bin/activate\n$ pip install -r requirements.txt\n$ python examples/example.py\n```\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "YDB Dialect for SQLAlchemy",
"version": "0.1.8",
"project_urls": {
"Homepage": "http://github.com/ydb-platform/ydb-sqlalchemy"
},
"split_keywords": [
"sqlalchemy",
"ydb",
"yql"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e35fb1e48fbc97cad07085e8b5777cb0f780605cd7489e197b3faf97a54cd0ee",
"md5": "93a3138e0621b394abd03e0b70114336",
"sha256": "49c09ef2120cc30a7fe4f0626615a7b660e6d660f7d5c817620ee1a5a4898cca"
},
"downloads": -1,
"filename": "ydb_sqlalchemy-0.1.8-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "93a3138e0621b394abd03e0b70114336",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 35738,
"upload_time": "2025-02-27T16:12:57",
"upload_time_iso_8601": "2025-02-27T16:12:57.825495Z",
"url": "https://files.pythonhosted.org/packages/e3/5f/b1e48fbc97cad07085e8b5777cb0f780605cd7489e197b3faf97a54cd0ee/ydb_sqlalchemy-0.1.8-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ce849d4c9f5087ac71ed4f907463b191696604add44692aa8f64fd07bde0a89e",
"md5": "9d581cd68f8d6bb7c2ab19c6122c198d",
"sha256": "5eccb2ddc2049a1e58fc69dc9febca9ff41cc8fd596c78b217d8cb878421b44b"
},
"downloads": -1,
"filename": "ydb_sqlalchemy-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "9d581cd68f8d6bb7c2ab19c6122c198d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 31178,
"upload_time": "2025-02-27T16:13:00",
"upload_time_iso_8601": "2025-02-27T16:13:00.650647Z",
"url": "https://files.pythonhosted.org/packages/ce/84/9d4c9f5087ac71ed4f907463b191696604add44692aa8f64fd07bde0a89e/ydb_sqlalchemy-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-27 16:13:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ydb-platform",
"github_project": "ydb-sqlalchemy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "sqlalchemy",
"specs": [
[
"<",
"3.0.0"
],
[
">=",
"1.4.0"
]
]
},
{
"name": "ydb",
"specs": [
[
">=",
"3.18.8"
]
]
},
{
"name": "ydb-dbapi",
"specs": [
[
">=",
"0.1.10"
]
]
}
],
"tox": true,
"lcname": "ydb-sqlalchemy"
}