https://github.com/ydb-platform/ydb-python-dbapi
Python DBAPI for YDB
https://github.com/ydb-platform/ydb-python-dbapi
Last synced: 5 months ago
JSON representation
Python DBAPI for YDB
- Host: GitHub
- URL: https://github.com/ydb-platform/ydb-python-dbapi
- Owner: ydb-platform
- License: apache-2.0
- Created: 2024-09-13T09:06:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-12-11T18:45:28.000Z (6 months ago)
- Last Synced: 2025-12-12T23:24:30.346Z (6 months ago)
- Language: Python
- Homepage:
- Size: 397 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# YDB Python DBAPI
## Introduction
Python DBAPI to `YDB`, which provides both sync and async drivers and complies with [PEP249](https://www.python.org/dev/peps/pep-0249/).
## Installation
```shell
pip install ydb-dbapi
```
## Usage
To establish a new DBAPI connection you should provide `host`, `port` and `database`:
```python
import ydb_dbapi
connection = ydb_dbapi.connect(
host="localhost", port="2136", database="/local"
) # sync connection
async_connection = await ydb_dbapi.async_connect(
host="localhost", port="2136", database="/local"
) # async connection
```
Usage of connection:
```python
with connection.cursor() as cursor:
cursor.execute("SELECT id, val FROM table")
row = cursor.fetchone()
rows = cursor.fetchmany(size=5)
rows = cursor.fetchall()
```
Usage of async connection:
```python
async with async_connection.cursor() as cursor:
await cursor.execute("SELECT id, val FROM table")
row = await cursor.fetchone()
rows = await cursor.fetchmany(size=5)
rows = await cursor.fetchall()
```