-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.py
44 lines (38 loc) · 1.03 KB
/
db.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
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
# @Time : 2024/3/17 17:10
# @Author : yangyuexiong
# @Email : [email protected]
# @File : db.py.py
# @Software: PyCharm
from utils.db_connect import db_url as mysql_db_url
from utils.db_connect import pg_db_url as postgres_db_url
from utils.db_connect import models_list
TORTOISE_CONFIG = {
"connections": {
"default": postgres_db_url,
# "mysql_db": mysql_db_url
},
"apps": {
# "models": {
# "models": models_list,
# "default_connection": "default",
# },
"postgres_models": {
"models": models_list,
"default_connection": "default",
},
# "mysql_models": {
# "models": models_list,
# "default_connection": "mysql_db",
# }
},
'use_tz': True, # 确保 Tortoise 使用带时区的 datetime
'timezone': 'Asia/Shanghai',
}
"""
aerich init -t db.TORTOISE_CONFIG
aerich init-db
aerich --app mysql_models init-db
aerich migrate --name test
aerich upgrade
"""