-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
28 lines (21 loc) · 654 Bytes
/
db.py
File metadata and controls
28 lines (21 loc) · 654 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from tortoise import Tortoise
db = Tortoise()
async def on_startup():
await db.init(config=TORTOISE_ORM)
async def on_shutdown():
await db.close_connections()
POSTGRES_HOST = "localhost"
POSTGRES_PORT = 5432
POSTGRES_PASSWORD = "aiohttp_security"
POSTGRES_USER = "aiohttp_security"
POSTGRES_DB = "aiohttp_security"
POSTGRES_URI = f"postgres://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_HOST}:{POSTGRES_PORT}/{POSTGRES_DB}"
TORTOISE_ORM = {
"connections": {"default": POSTGRES_URI},
"apps": {
"models": {
"models": ["models", "aerich.models"],
"default_connection": "default",
},
},
}