Django backend for YDB
Project description
django-ydb-backend
A Django database backend for YDB, a distributed SQL database. It lets Django applications use YDB through the standard ORM — models, migrations, queries, relations, and the contrib apps.
Documentation · PyPI · YDB · Issues
Features
- Django ORM for CRUD, relations, and the standard contrib apps (admin, auth, sessions)
- Most built-in Django field types
- Migrations with YDB-specific adaptations
- Native, race-free
UPSERTviaYDBManager - Multiple authentication methods (anonymous, static, access token, service account)
Quick start
Install:
pip install django-ydb-backend
To develop against a local database, start YDB in Docker:
docker run -d --name ydb-local --hostname localhost \
-p 2136:2136 -p 8765:8765 \
-e YDB_USE_IN_MEMORY_PDISKS=true \
ydbplatform/local-ydb:latest
This serves a ready-to-use database at /local on localhost:2136 — the values
used below. Then point a Django database at YDB in settings.py:
DATABASES = {
"default": {
"ENGINE": "ydb_backend.backend",
"NAME": "ydb_db",
"HOST": "localhost",
"PORT": "2136",
"DATABASE": "/local",
}
}
Define a model, migrate, and query as usual:
from django.db import models
class Product(models.Model):
sku = models.CharField(max_length=20, primary_key=True)
name = models.CharField(max_length=100)
price = models.IntegerField()
python manage.py makemigrations
python manage.py migrate
Product.objects.create(sku="A1", name="Widget", price=9)
Product.objects.filter(price__lt=10)
See the documentation for configuration and authentication, fields, migrations, queries, transactions, and UPSERT.
Good to know
YDB is a distributed database and does not behave exactly like PostgreSQL or MySQL. A few things to keep in mind:
- It does not enforce foreign keys, uniqueness, or check constraints — enforce these in application code.
- There are no savepoints, so Django's
TestCaseand nestedatomic()rollback do not work — useTransactionTestCasefor database tests. - Primary-key-only and multi-table-inheritance models cannot be inserted — give every model at least one non-primary-key field.
The full list and the supported version matrix are in Compatibility and limitations.
Requirements
Development
This project uses uv for dependency and
environment management (uv also provisions the right Python, so a local
Python install is not required).
git clone https://github.com/ydb-platform/django-ydb-backend.git
cd django-ydb-backend
docker compose up -d --wait # local YDB; requires docker + docker compose
uv sync # installs uv-managed Python + dependencies
uv run python tests/runtests.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_ydb_backend-0.0.1b7.tar.gz.
File metadata
- Download URL: django_ydb_backend-0.0.1b7.tar.gz
- Upload date:
- Size: 54.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39eb3b24f6ea6a18d5ec8043e3db820fed2ea911fa8d84704fb19e5190187498
|
|
| MD5 |
a77ac6b3fc4dafc8207f00ed28dbccc2
|
|
| BLAKE2b-256 |
eb1ae9f37ebd90f39ccaca10eb95cfa054f4a7d9c6d25a75f68a5c46fec519a3
|
Provenance
The following attestation bundles were made for django_ydb_backend-0.0.1b7.tar.gz:
Publisher:
python-publish.yml on ydb-platform/django-ydb-backend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_ydb_backend-0.0.1b7.tar.gz -
Subject digest:
39eb3b24f6ea6a18d5ec8043e3db820fed2ea911fa8d84704fb19e5190187498 - Sigstore transparency entry: 1954482722
- Sigstore integration time:
-
Permalink:
ydb-platform/django-ydb-backend@62d1334856ef0159c667cdf503477120c35c8a58 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ydb-platform
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@62d1334856ef0159c667cdf503477120c35c8a58 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file django_ydb_backend-0.0.1b7-py3-none-any.whl.
File metadata
- Download URL: django_ydb_backend-0.0.1b7-py3-none-any.whl
- Upload date:
- Size: 52.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e42439f271011f7654bcc5d0842c97bd4974a5f54d505bb9b36ef921df2b5c4
|
|
| MD5 |
1ed6a71b410fe14e0bd12af1e408ac9d
|
|
| BLAKE2b-256 |
306c56d078f1318bc674b2cf9e415daf60b5f3ef360d6848a4e9ba277e01438d
|
Provenance
The following attestation bundles were made for django_ydb_backend-0.0.1b7-py3-none-any.whl:
Publisher:
python-publish.yml on ydb-platform/django-ydb-backend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_ydb_backend-0.0.1b7-py3-none-any.whl -
Subject digest:
0e42439f271011f7654bcc5d0842c97bd4974a5f54d505bb9b36ef921df2b5c4 - Sigstore transparency entry: 1954483065
- Sigstore integration time:
-
Permalink:
ydb-platform/django-ydb-backend@62d1334856ef0159c667cdf503477120c35c8a58 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ydb-platform
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@62d1334856ef0159c667cdf503477120c35c8a58 -
Trigger Event:
workflow_dispatch
-
Statement type: