Skip to main content

Django backend for YDB

Project description

django-ydb-backend

PyPI Python Django Tests codecov

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 UPSERT via YDBManager
  • 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 TestCase and nested atomic() rollback do not work — use TransactionTestCase for 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_ydb_backend-0.0.1b7.tar.gz (54.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_ydb_backend-0.0.1b7-py3-none-any.whl (52.3 kB view details)

Uploaded Python 3

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

Hashes for django_ydb_backend-0.0.1b7.tar.gz
Algorithm Hash digest
SHA256 39eb3b24f6ea6a18d5ec8043e3db820fed2ea911fa8d84704fb19e5190187498
MD5 a77ac6b3fc4dafc8207f00ed28dbccc2
BLAKE2b-256 eb1ae9f37ebd90f39ccaca10eb95cfa054f4a7d9c6d25a75f68a5c46fec519a3

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_ydb_backend-0.0.1b7-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ydb_backend-0.0.1b7-py3-none-any.whl
Algorithm Hash digest
SHA256 0e42439f271011f7654bcc5d0842c97bd4974a5f54d505bb9b36ef921df2b5c4
MD5 1ed6a71b410fe14e0bd12af1e408ac9d
BLAKE2b-256 306c56d078f1318bc674b2cf9e415daf60b5f3ef360d6848a4e9ba277e01438d

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page