Skip to main content

Tortoise ORM backend for DuckDB

This integration allows you to use asyncio duckdb APIs with Tortoise ORM.

Install

tortoise-orm-extra-duckdb is compatible with Python 3.11 and newer. You can install it from PyPI:

$ pip install tortoise-orm-extra-duckdb

Usage

It is very simple to use. You only need to add two lines of code to the original project and switch the database to duckdb.

import asyncio

from tortoise import Tortoise, fields, run_async
from tortoise.models import Model
+ from tortoise.patch import monkey_patch


class Event(Model):
    id = fields.IntField(primary_key=True)
    name = fields.TextField(description="Name of the event that corresponds to an action")
    datetime = fields.DatetimeField(
        null=True, description="Datetime of when the event was generated"
    )

    class Meta:
        table = "event"
        table_description = "This table contains a list of all the example events"

    def __str__(self):
        return self.name


async def main():
~   await Tortoise.init(db_url="duckdb://:memory:", modules={"models": ["__main__"]})
    await Tortoise.generate_schemas()

    event = await Event.create(id=1, name="Test")
    await Event.filter(id=event.id).update(name="Updated name")

    print(await Event.filter(name="Updated name").first())

    await Event(id=2, name="Test 2").save()
    print(await Event.all().values_list("id", flat=True))
    print(await Event.all().values("id", "name"))


if __name__ == "__main__":
+   monkey_patch()
    asyncio.run(main())

License

tortoise-orm-extra-duckdb is licensed under the MIT license. I am providing code in this repository to you under an open source license. This is my personal repository; the license you receive to my code is from me and not from my employer. See the LICENSE file for details.

Release files for tortoise-orm-extra-duckdb 2025.9.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tortoise-orm-extra-duckdb 2025.9.15
File Size Uploaded
tortoise_orm_extra_duckdb-2025.9.15.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tortoise-orm-extra-duckdb 2025.9.15
File Interpreter ABI Platform
tortoise_orm_extra_duckdb-2025.9.15-py3-none-any.whl Python 3 none any Details

Total release size: 22.7 kB

Release files / tortoise_orm_extra_duckdb-2025.9.15.tar.gz

Download URL tortoise_orm_extra_duckdb-2025.9.15.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0a0d3769e4dcf56adf12d955749a5b3c29691de9499150c98fd9271f3385dd47
BLAKE2b-256 checksum
How to use checksums
ecc3effdb820e8205b10907e1588b1d92039f266f67ffa6748c6faf12e92d748
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2025.

Transparency log

Release files / tortoise_orm_extra_duckdb-2025.9.15-py3-none-any.whl

Download URL tortoise_orm_extra_duckdb-2025.9.15-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d36c691450d781ffc8609c82594681443b42d24b97116fd479aa5bc2f43b7a7
BLAKE2b-256 checksum
How to use checksums
9084eec2310ce2a4aacd2273f4a81eacc4e1e0102a4250e1b0b3fcaa7ee60384
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

2025.9.15 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page