-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
31 lines (25 loc) · 827 Bytes
/
settings.py
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
29
30
31
from decouple import config
from pydantic import BaseSettings
DB_MODELS = ["apps.user.models", 'apps.products.models', 'aerich.models', 'apps.authtoken.models']
SQLITE_DB_URL = f"postgres://postgres:{config('POSTGRES_PASSWORD')}@localhost:5432/app"
class TortoiseSettings(BaseSettings):
"""Tortoise-ORM settings"""
db_url: str
modules: dict
generate_schemas: bool
@classmethod
def generate(cls):
db_url = SQLITE_DB_URL
modules = {"models": DB_MODELS}
return TortoiseSettings(db_url=db_url,modules=modules,generate_schemas=True)
@classmethod
def migration_dict(cls):
return {
"connections": {"default": SQLITE_DB_URL},
"apps": {
"models": {
"models": DB_MODELS,
"default_connection": "default",
},
},
}