Created
May 10, 2022 23:09
-
-
Save PythonCoderAS/4731e2017689f5f73ab9db6b16db846c to your computer and use it in GitHub Desktop.
Template for postgres aerich-compatible tortoise ORM configuration file #tortoise-orm #postgres #asyncpg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from tortoise import Tortoise | |
| project_db = "test" | |
| TORTOISE_ORM = { | |
| "connections": { | |
| "default": { | |
| "engine": "tortoise.backends.asyncpg", | |
| "credentials": { | |
| "user": project_db, | |
| "password": project_db, | |
| "database": project_db, | |
| "host": "localhost", | |
| "port": 5432, | |
| }, | |
| }, | |
| }, | |
| "apps": { | |
| "models": { | |
| "models": [__name__, "aerich.models"], | |
| "default_connection": "default", | |
| }, | |
| }, | |
| "use_tz": True, | |
| "maxsize": 20, | |
| } | |
| async def init(): | |
| """Initialize the ORM.""" | |
| # Here we connect to a SQLite DB file. | |
| # also specify the app name of "models" | |
| # which contain models from "app.models" | |
| await Tortoise.init(TORTOISE_ORM) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment