tortoise-orm
Easy async ORM for python, built with relations in mind
What it is and what it does
Tortoise ORM is an async-native Object-Relational Mapper inspired by Django, designed to let developers work with relational databases using Python objects instead of raw SQL. It abstracts database interactions across SQLite, MySQL, PostgreSQL, Microsoft SQL Server, and Oracle, reducing boilerplate, preventing SQL injection through parameterized queries, and centralizing schema definitions. The package is built on asyncio and integrates with async frameworks.
You define models by inheriting from tortoise.models.Model, then initialize Tortoise to establish relationships and connect to your database. Once initialized, you can create, filter, and query records using async methods like .create(), .filter(), and .prefetch_related(). The package includes a built-in migration CLI for version-controlled schema changes, and supports complex operations like many-to-many relationships, nested prefetching, and filtering across related models.
Use it for:
- Building async web APIs where you need to query databases without blocking the event loop.
- Defining and managing relational schemas with version-controlled migrations in production applications.
- Reducing SQL boilerplate in projects that work with multiple database backends (PostgreSQL, MySQL, SQLite, Oracle).
- Implementing complex queries involving foreign keys, many-to-many relationships, and nested filtering across related models.
- Preventing SQL injection vulnerabilities by using parameterized queries through an ORM abstraction layer.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Tortoise ORM is an async-native Object-Relational Mapper for Python that lets you define and query databases using high-level object-oriented code instead of raw SQL, with support for SQLite, MySQL, PostgreSQL, Microsoft SQL Server, and Oracle.
Yes. Tortoise ORM is actively maintained, has low install friction, carries no known vulnerabilities, and is licensed permissively under Apache-2.0. It is a solid choice for async Python projects that need to work with relational databases and want a Django-like API. Install it if you are building async applications and prefer ORM abstraction over raw SQL; skip it if you need synchronous database access or prefer a different query style.
Install
tortoise-orm on PyPI
pip
pip install tortoise-ormuv
uv add tortoise-ormpoetry
poetry add tortoise-ormInstalling tortoise-orm
Before you install
Low friction installation with a pure-Python wheel. Active maintenance with a recent release and 5609 repository stars. Supports CPython 3.10 and later across multiple platforms.
License in practice
Licensed under Apache-2.0 (permissive), allowing commercial and private use with minimal restrictions—suitable for most projects.
Quickstart
pip install tortoise-orm
from tortoise import Tortoise, fields
from tortoise.models import Model
class User(Model):
id = fields.IntField(primary_key=True)
name = fields.CharField(max_length=20)
await Tortoise.init(
db_url='sqlite://db.sqlite3',
modules={'models': ['__main__']}
)
await Tortoise.generate_schemas()
user = await User.create(name='Alice')
print(user.name)
Requires Python 3.10 or later; database-specific drivers (aiosqlite, asyncpg, aiomysql, etc.) must be installed separately via extras (e.g., pip install tortoise-orm[asyncpg]).
Verify before relying
- Performance characteristics and overhead compared to raw SQL or other async ORMs in production workloads.
- Maturity of migration system and real-world experience with complex schema evolution.
- Community size and availability of third-party extensions or integrations beyond documented frameworks.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — pypika-tortoise, iso8601, aiosqlite, anyio, tomlkit, typing-extensions |
| Maintenance | actively maintained — 4 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 636,466/month — #5,626 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tortoise_orm-1.1.8-py3-none-any.whl
Keywords: sql, mysql, postgres, psql, sqlite, aiosqlite, asyncpg, relational, database, rdbms, orm, object mapper, async, asyncio, aio, psycopg
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
aerichAerich is a database migration tool for…
permissive · top 15,000 on PyPI
ponyPony is an object-relational mapper that lets…
permissive · top 15,000 on PyPI
pypika-tortoiseGenerates SQL queries programmatically for…
permissive · top 15,000 on PyPI
SQLAlchemySQLAlchemy is a Python SQL toolkit and Object…
permissive · top 100 on PyPI
opentelemetry-instrumentation-tortoiseormAdds distributed tracing to Tortoise ORM…
permissive · top 5,000 on PyPI
prismaPrisma Client Python is a type-safe ORM that…
permissive · top 5,000 on PyPI
ormarAn async ORM for Python that unifies database…
permissive · top 15,000 on PyPI
async-factory-boyExtends factory_boy to generate test fixtures…
permissive · top 15,000 on PyPI
peeweePeewee is a lightweight ORM that maps Python…
unclear · top 1,000 on PyPI
databasesProvides async database access for PostgreSQL,…
permissive · top 5,000 on PyPI