Skip to main content

An asynchronous ORM inspired by Django's ORM, built on top of SQLAlchemy.

Project description

AsyncDjangoORM

AsyncDjangoORM is an asynchronous ORM inspired by Django's ORM, built on top of SQLAlchemy. It provides Django-like Querysets and AsyncManagers, allowing you to interact with databases using Python async/await.

Ideal for telegram bots while building application with aiogram

Features

Full async support using async/await.

Django-style Queryset and AsyncManager.

CRUD operations: get, create, get_or_create, update_or_create.

Query methods: filter, exclude, order_by, annotate, aggregate, bulk_create, bulk_update, bulk_delete.

Relation handling: select_related and prefetch_related.

Supports PostgreSQL, MySQL, and SQLite.

Lightweight, flexible, and easy to integrate.

Installation

Install via pip:

pip install asyncdjangoorm


# PostgreSQL
pip install asyncdjangoorm[postgres]

# MySQL
pip install asyncdjangoorm[mysql]

# SQLite (default)
pip install asyncdjangoorm[sqlite]

Database Configuration

SQLite (default)

export DATABASE_URL="sqlite+aiosqlite:///./mydb.db"

PostgreSQL (asyncpg)

export DATABASE_URL="postgresql+asyncpg://user:password@localhost:5432/mydb"

MySQL (aiomysql)

export DATABASE_URL="mysql+aiomysql://user:password@localhost:3306/mydb"

from asyncdjangoorm import AsyncManager from your_models import MyModel # import your models

async def main(): # Fetch all objects asynchronously objects = await MyModel.objects.all() print(objects)

# Create a new object
await MyModel.objects.create(name="Test", value=42)

# Get or create an object
obj, created = await MyModel.objects.get_or_create(name="Example")

# Filter objects
filtered = await MyModel.objects.filter(value__gt=10)

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

asyncdjangoorm-0.1.2.tar.gz (240.9 kB view details)

Uploaded Source

File details

Details for the file asyncdjangoorm-0.1.2.tar.gz.

File metadata

  • Download URL: asyncdjangoorm-0.1.2.tar.gz
  • Upload date:
  • Size: 240.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for asyncdjangoorm-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a4dba4527c34e111dc86df6a1df213d6f418e37d2b7df6c3e1f6ac68177f7022
MD5 aa1bad5f3fb93972236f5a44650e1481
BLAKE2b-256 c7fb98bffe0c0dca1f78ef19e2148ceaaab58041235f5a5e5341aaebd027e623

See more details on using hashes here.

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