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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tortoise_orm_extra_duckdb-2025.9.1.tar.gz.
File metadata
- Download URL: tortoise_orm_extra_duckdb-2025.9.1.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
034d6f422ed1d915c8fed2180535df3bedc067ef80df869b4dbb7ddcfb4aae90
|
|
| MD5 |
2b8cfa47461d47d856d06b521ce678fd
|
|
| BLAKE2b-256 |
f4329cf2f01b0d6c847bd090380c5cdc48d0317320c63b9678156eaa5b897414
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tortoise_orm_extra_duckdb-2025.9.1.tar.gz -
Subject digest:
034d6f422ed1d915c8fed2180535df3bedc067ef80df869b4dbb7ddcfb4aae90 - Sigstore transparency entry: 454963677
- Sigstore integration time:
-
Permalink:
cnfairydream/tortoise-orm-extra-duckdb@4c8eb8be5f08eab462bbcaba83877a1ae19f16c2 -
Branch / Tag:
refs/tags/2025.9.1 - Owner: https://github.com/cnfairydream
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4c8eb8be5f08eab462bbcaba83877a1ae19f16c2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file tortoise_orm_extra_duckdb-2025.9.1-py3-none-any.whl.
File metadata
- Download URL: tortoise_orm_extra_duckdb-2025.9.1-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3e3f26c600dee703d4e941ea149ffd22b450c5629f5985aa5a7b8c248b3c7d4
|
|
| MD5 |
a5037f059cec97381466be71171ce118
|
|
| BLAKE2b-256 |
df48346f95549fb9af124549c9ba82da52ee2f55065d8c8b1ee54db2445720f2
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tortoise_orm_extra_duckdb-2025.9.1-py3-none-any.whl -
Subject digest:
d3e3f26c600dee703d4e941ea149ffd22b450c5629f5985aa5a7b8c248b3c7d4 - Sigstore transparency entry: 454963698
- Sigstore integration time:
-
Permalink:
cnfairydream/tortoise-orm-extra-duckdb@4c8eb8be5f08eab462bbcaba83877a1ae19f16c2 -
Branch / Tag:
refs/tags/2025.9.1 - Owner: https://github.com/cnfairydream
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4c8eb8be5f08eab462bbcaba83877a1ae19f16c2 -
Trigger Event:
release
-
Statement type: