Skip to main content

Tortoise ORM backend for DuckDB

Project description

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.

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

tortoise_orm_extra_duckdb-2025.9.1.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

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

tortoise_orm_extra_duckdb-2025.9.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file tortoise_orm_extra_duckdb-2025.9.1.tar.gz.

File metadata

File hashes

Hashes for tortoise_orm_extra_duckdb-2025.9.1.tar.gz
Algorithm Hash digest
SHA256 034d6f422ed1d915c8fed2180535df3bedc067ef80df869b4dbb7ddcfb4aae90
MD5 2b8cfa47461d47d856d06b521ce678fd
BLAKE2b-256 f4329cf2f01b0d6c847bd090380c5cdc48d0317320c63b9678156eaa5b897414

See more details on using hashes here.

Provenance

The following attestation bundles were made for tortoise_orm_extra_duckdb-2025.9.1.tar.gz:

Publisher: publish.yml on cnfairydream/tortoise-orm-extra-duckdb

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

File details

Details for the file tortoise_orm_extra_duckdb-2025.9.1-py3-none-any.whl.

File metadata

File hashes

Hashes for tortoise_orm_extra_duckdb-2025.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d3e3f26c600dee703d4e941ea149ffd22b450c5629f5985aa5a7b8c248b3c7d4
MD5 a5037f059cec97381466be71171ce118
BLAKE2b-256 df48346f95549fb9af124549c9ba82da52ee2f55065d8c8b1ee54db2445720f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for tortoise_orm_extra_duckdb-2025.9.1-py3-none-any.whl:

Publisher: publish.yml on cnfairydream/tortoise-orm-extra-duckdb

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