{"id":29760802,"url":"https://github.com/ydb-platform/ydb-sqlalchemy","last_synced_at":"2026-02-05T17:07:03.624Z","repository":{"id":163533564,"uuid":"621800921","full_name":"ydb-platform/ydb-sqlalchemy","owner":"ydb-platform","description":"YQL Dialect for SQLAlchemy","archived":false,"fork":false,"pushed_at":"2026-01-28T11:33:55.000Z","size":380,"stargazers_count":35,"open_issues_count":23,"forks_count":12,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-01-29T02:16:54.022Z","etag":null,"topics":["sqlalchemy","ydb","ydb-platform","ydb-sdk"],"latest_commit_sha":null,"homepage":"https://ydb-platform.github.io/ydb-sqlalchemy/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ydb-platform.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-03-31T12:16:56.000Z","updated_at":"2026-01-28T11:33:58.000Z","dependencies_parsed_at":"2023-12-15T07:26:45.255Z","dependency_job_id":"fe19cc2b-d17d-490a-9be2-20e911b33113","html_url":"https://github.com/ydb-platform/ydb-sqlalchemy","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"purl":"pkg:github/ydb-platform/ydb-sqlalchemy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydb-platform%2Fydb-sqlalchemy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydb-platform%2Fydb-sqlalchemy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydb-platform%2Fydb-sqlalchemy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydb-platform%2Fydb-sqlalchemy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ydb-platform","download_url":"https://codeload.github.com/ydb-platform/ydb-sqlalchemy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ydb-platform%2Fydb-sqlalchemy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29126155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T14:05:12.718Z","status":"ssl_error","status_checked_at":"2026-02-05T14:03:53.078Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sqlalchemy","ydb","ydb-platform","ydb-sdk"],"created_at":"2025-07-26T20:21:26.864Z","updated_at":"2026-02-05T17:07:03.609Z","avatar_url":"https://github.com/ydb-platform.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YDB Dialect for SQLAlchemy\n---\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/ydb-platform/ydb-sqlalchemy/blob/main/LICENSE)\n[![PyPI version](https://badge.fury.io/py/ydb-sqlalchemy.svg)](https://badge.fury.io/py/ydb-sqlalchemy)\n[![API Reference](https://img.shields.io/badge/API-Reference-lightgreen.svg)](https://ydb-platform.github.io/ydb-sqlalchemy/api/index.html)\n[![Functional tests](https://github.com/ydb-platform/ydb-sqlalchemy/actions/workflows/tests.yml/badge.svg)](https://github.com/ydb-platform/ydb-sqlalchemy/actions/workflows/tests.yml)\n[![Style checks](https://github.com/ydb-platform/ydb-sqlalchemy/actions/workflows/style.yml/badge.svg)](https://github.com/ydb-platform/ydb-sqlalchemy/actions/workflows/style.yml)\n\nThis repository contains YQL dialect for SqlAlchemy 2.0.\n\n---\n\n**Documentation**: \u003ca href=\"https://ydb-platform.github.io/ydb-sqlalchemy\" target=\"_blank\"\u003ehttps://ydb-platform.github.io/ydb-sqlalchemy\u003c/a\u003e\n\n---\n\n**Note**: Dialect also works with SqlAlchemy 1.4, but it is not fully tested.\n\n\n## Installation\n\n### Via PyPI\nTo install ydb-sqlalchemy from PyPI:\n\n```bash\n$ pip install ydb-sqlalchemy\n```\n\n### Installation from source code\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\n## Authentication\n\nTo specify credentials, you should pass `credentials` object to `connect_args` argument of `create_engine` method.\n\n### Static Credentials\n\nTo use static credentials you should specify `username` and `password` as follows:\n\n```python3\nengine = sa.create_engine(\n    \"yql+ydb://localhost:2136/local\",\n    connect_args = {\n        \"credentials\": {\n            \"username\": \"...\",\n            \"password\": \"...\"\n        }\n    }\n)\n```\n\n### Token Credentials\n\nTo use access token credentials you should specify `token` as follows:\n\n```python3\nengine = sa.create_engine(\n    \"yql+ydb://localhost:2136/local\",\n    connect_args = {\n        \"credentials\": {\n            \"token\": \"...\"\n        }\n    }\n)\n```\n\n### Service Account Credentials\n\nTo use service account credentials you should specify `service_account_json` as follows:\n\n```python3\nengine = sa.create_engine(\n    \"yql+ydb://localhost:2136/local\",\n    connect_args = {\n        \"credentials\": {\n            \"service_account_json\": {\n                \"id\": \"...\",\n                \"service_account_id\": \"...\",\n                \"created_at\": \"...\",\n                \"key_algorithm\": \"...\",\n                \"public_key\": \"...\",\n                \"private_key\": \"...\"\n            }\n        }\n    }\n)\n```\n\n### Credentials from YDB SDK\n\nTo use any credentials that comes with `ydb` package, just pass credentials object as follows:\n\n```python3\nimport ydb.iam\n\nengine = sa.create_engine(\n    \"yql+ydb://localhost:2136/local\",\n    connect_args = {\n        \"credentials\": ydb.iam.MetadataUrlCredentials()\n    }\n)\n\n```\n\n\n## Migrations\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\n## Additional Notes\n\n### Pandas\nIt is possible to use YDB SA engine with `pandas` fuctions [to_sql()](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_sql.html) and [read_sql](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_sql.html). However, there are some limitations:\n\n* `to_sql` method can not be used with column tables, since it is impossible to specify `NOT NULL` columns with current `to_sql` arguments. YDB requires column tables to have `NOT NULL` attribute on `PK` columns.\n\n* `to_sql` is not fully optimized to load huge datasets. It is recommended to use `method=\"multi\"` and avoid setting a very large `chunksize`.\n\n* `read_sql` is not fully optimized to load huge datasets and could lead to significant memory consumptions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fydb-platform%2Fydb-sqlalchemy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fydb-platform%2Fydb-sqlalchemy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fydb-platform%2Fydb-sqlalchemy/lists"}