Official Python client for YDB — a fault-tolerant distributed SQL DBMS.
| Path | Purpose |
|---|---|
ydb/ |
Synchronous client — canonical implementation |
ydb/aio/ |
Async client — mirrors ydb/ API exactly |
ydb/_grpc/v3/ … v6/ |
Auto-generated protobuf stubs — never edit |
ydb/*_test.py |
Unit tests (fast, no Docker required) |
tests/ |
Integration tests (require Docker, auto-started by pytest) |
examples/ |
Usage examples |
docs/ |
User-facing documentation |
python3 -m venv .venv
source .venv/bin/activate
pip install -e . toxAlways activate the virtual environment before running any project commands.
# Auto-fix formatting
tox -e black-format
# Check formatting
tox -e black
# Style (flake8)
tox -e style
# Type checking
tox -e mypyBefore submitting a PR, run all checks and unit tests:
tox -e black && tox -e style && tox -e mypy && tox -e py -- ydb -v# Unit tests — fast, no Docker needed
source .venv/bin/activate && tox -e py -- ydb -v
# Integration tests — Docker started automatically by pytest-docker, do NOT start it manually
source .venv/bin/activate && tox -e py -- tests -v
# Single test file
source .venv/bin/activate && tox -e py -- tests/path/to/test_file.py -vAlways run the relevant tests after implementing a feature or fix.
- Backward compatibility — never break the public API; only extend it.
- Sync/async parity — every change in
ydb/must be mirrored inydb/aio/. - Tests required — all changes must have tests; add to existing test files, do not create new ones.
- No new dependencies — the current dependency set is intentionally minimal.
- No excessive comments — do not comment self-evident code.
- English only — code, comments, docstrings, commit messages.
- Python 3.8+ — do not use language or stdlib features beyond that baseline.
- Update
docs/for any user-facing changes; create new sections if needed. - Extend
examples/when adding new features. - After every change to
docs/, rebuild the HTML output and verify there are no new errors:source .venv/bin/activate && sphinx-build -b html docs docs/_build/html -q
ydb/_grpc/v3/
ydb/_grpc/v4/
ydb/_grpc/v5/
ydb/_grpc/v6/
To regenerate protobuf stubs: see Makefile and generate-protobuf.Dockerfile.
Run this only for changes that affect topic reader/writer reconnection logic.
1. Start YDB with chaos (kills a DB node every ~20 seconds):
docker compose -f tests/slo/playground/configs/compose.yaml up -d2. Wait until YDB is healthy:
docker ps --format "table {{.Names}}\t{{.Status}}" | grep ydb3. Create a test topic (from tests/slo/ directory):
source .venv/bin/activate
python ./src topic-create grpc://localhost:2135 /Root/testdb \
--path /Root/testdb/slo_topic --debug4. Test writer (60 sec):
python ./src topic-run grpc://localhost:2135 /Root/testdb \
--path /Root/testdb/slo_topic --otlp-endpoint "" \
--read-threads 0 --write-rps 1 --time 60 --debug5. Test reader (60 sec):
python ./src topic-run grpc://localhost:2135 /Root/testdb \
--path /Root/testdb/slo_topic --otlp-endpoint "" \
--read-rps 1 --write-threads 0 --time 60 --debug6. Tear down:
docker compose -f tests/slo/playground/configs/compose.yaml downSuccess criteria: writer and reader reconnect automatically during node restarts with no fatal errors.