Aurora DSQL adapter for Tortoise ORM
Project description
Aurora DSQL Adapter for Tortoise ORM
An adapter for building Tortoise ORM applications with Amazon Aurora DSQL.
Requirements
- Tortoise ORM: 0.25 or later
- Python: 3.10 or later (installation guide)
- AWS Credentials: Valid credentials configured for IAM database authentication. The adapter generates a new auth token for each connection.
- Aerich (optional): 0.9.2 or later, if using Aerich for migrations
Getting Started
Install the adapter with your preferred async driver:
# asyncpg
pip install aurora-dsql-tortoise-orm[asyncpg]
# psycopg
pip install aurora-dsql-tortoise-orm[psycopg]
Configuration
Configure your connection using the DSQL engine:
TORTOISE_ORM = {
"connections": {
"default": {
"engine": "aurora_dsql_tortoise.asyncpg", # or "aurora_dsql_tortoise.psycopg"
"credentials": {
"host": "<cluster_id>.dsql.<region>.on.aws",
"user": "admin",
},
}
},
"apps": {
"models": {
"models": ["your.models"],
"default_connection": "default",
}
},
}
The adapter accepts all parameters supported by the underlying asyncpg or psycopg driver, as well as the Aurora DSQL Connector for Python.
Or use a connection URL (requires registering the backend first):
from aurora_dsql_tortoise import register_backends
register_backends()
TORTOISE_ORM = {
"connections": {
"default": "dsql+asyncpg://admin@<cluster_id>.dsql.<region>.on.aws/postgres"
},
"apps": {
"models": {
"models": ["your.models"],
"default_connection": "default",
}
},
}
Defining Models
UUID primary keys are recommended for optimal performance with Aurora DSQL:
import uuid
from tortoise import fields
from tortoise.models import Model
class Owner(Model):
id = fields.UUIDField(primary_key=True, default=uuid.uuid4)
name = fields.CharField(max_length=100)
class Meta:
table = "owner"
Aerich Migrations
For database migrations with Aerich, include the compatibility module:
TORTOISE_ORM = {
"connections": {"default": {...}},
"apps": {
"models": {
"models": [
"your.models",
"aerich.models",
"aurora_dsql_tortoise.aerich_compat",
],
"default_connection": "default",
}
},
}
The compatibility module patches Aerich to:
- Use UUID primary keys for migration tracking
- Execute DDL statements individually (DSQL transactions support only one DDL statement)
- Use TEXT instead of JSON column types
Features and Limitations
- Adapter Behavior - How the adapter modifies Tortoise ORM behavior for Aurora DSQL compatibility
- Known Issues - Known limitations and workarounds
Development
Install uv, then:
git clone https://github.com/awslabs/aurora-dsql-orms
cd aurora-dsql-orms/python/tortoise-orm
uv sync
Running Tests
⚠️ Running integration tests may result in charges to your AWS account.
Unit tests:
uv run unit
Integration tests (requires a DSQL cluster):
cp .env.example .env
# Edit .env with your cluster endpoint
uv run integration
Getting Help
- Open a support ticket with AWS Support
- Report bugs via GitHub Issues
Additional Resources
Opening Issues
If you encounter a bug, please search existing issues before opening a new one. GitHub issues are intended for bug reports and feature requests.
License
This library is licensed under the Apache 2.0 License.
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
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 aurora_dsql_tortoise_orm-0.1.4.tar.gz.
File metadata
- Download URL: aurora_dsql_tortoise_orm-0.1.4.tar.gz
- Upload date:
- Size: 75.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09a8885ce06bd169dbc6421ca82a74fc0f753da63837314eed870bda741dded2
|
|
| MD5 |
4501e046c0dec404e792282738a232a5
|
|
| BLAKE2b-256 |
57a942ed76fcb3cb574ff61093183bceee2c969131610e203cd3a8d29ee299f6
|
Provenance
The following attestation bundles were made for aurora_dsql_tortoise_orm-0.1.4.tar.gz:
Publisher:
python-tortoise-release.yml on awslabs/aurora-dsql-orms
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aurora_dsql_tortoise_orm-0.1.4.tar.gz -
Subject digest:
09a8885ce06bd169dbc6421ca82a74fc0f753da63837314eed870bda741dded2 - Sigstore transparency entry: 874416334
- Sigstore integration time:
-
Permalink:
awslabs/aurora-dsql-orms@8d3fc12680ef36f882549e9a98214ef3630d44a4 -
Branch / Tag:
refs/tags/python/tortoise-orm/v0.1.4 - Owner: https://github.com/awslabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-tortoise-release.yml@8d3fc12680ef36f882549e9a98214ef3630d44a4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aurora_dsql_tortoise_orm-0.1.4-py3-none-any.whl.
File metadata
- Download URL: aurora_dsql_tortoise_orm-0.1.4-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7013a49b1acfe2820011d658ac269dc89d258c697e59cc44b3716627c1a7f511
|
|
| MD5 |
8bc5336caa2809bebbbf137e999d9fb0
|
|
| BLAKE2b-256 |
08975ba28f311bc5026375928aebb34dd24829920c7b2fe5ce439d375424bd0b
|
Provenance
The following attestation bundles were made for aurora_dsql_tortoise_orm-0.1.4-py3-none-any.whl:
Publisher:
python-tortoise-release.yml on awslabs/aurora-dsql-orms
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aurora_dsql_tortoise_orm-0.1.4-py3-none-any.whl -
Subject digest:
7013a49b1acfe2820011d658ac269dc89d258c697e59cc44b3716627c1a7f511 - Sigstore transparency entry: 874416386
- Sigstore integration time:
-
Permalink:
awslabs/aurora-dsql-orms@8d3fc12680ef36f882549e9a98214ef3630d44a4 -
Branch / Tag:
refs/tags/python/tortoise-orm/v0.1.4 - Owner: https://github.com/awslabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-tortoise-release.yml@8d3fc12680ef36f882549e9a98214ef3630d44a4 -
Trigger Event:
push
-
Statement type: