YDB Dialect for SQLAlchemy
Actively maintained. Last release 3 months ago, commits in 4 of the last 26 weeks. A safe choice.
pip install ydb-sqlalchemyYDB Dialect for SQLAlchemy
This repository contains YQL dialect for SqlAlchemy 2.0.
Documentation: https://ydb-platform.github.io/ydb-sqlalchemy
Note: Dialect also works with SqlAlchemy 1.4, but it is not fully tested.
Installation
Via PyPI
To install ydb-sqlalchemy from PyPI:
$ pip install ydb-sqlalchemy
Installation from source code
To work with current ydb-sqlalchemy version clone this repo and run from source root:
$ pip install -U .
Getting started
Connect to local YDB using SqlAlchemy:
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())
Authentication
To specify credentials, you should pass credentials object to connect_args argument of create_engine method.
Static Credentials
To use static credentials you should specify username and password as follows:
engine = sa.create_engine(
"yql+ydb://localhost:2136/local",
connect_args = {
"credentials": {
"username": "...",
"password": "..."
}
}
)