35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
TORTOISE_ORM = {
|
||
'connections': {
|
||
'default': {
|
||
# 'engine': 'tortoise.backends.asyncpg', PostgreSQL
|
||
'engine': 'tortoise.backends.mysql', # MySQL or Mariadb
|
||
'credentials': {
|
||
'host': '192.168.11.67',
|
||
'port': 3306,
|
||
'user': 'country',
|
||
'password': 'sWdFeXMmAbHE5MXj',
|
||
'database': 'country',
|
||
'minsize': 10, # 最小连接数设为10,避免连接过多
|
||
'maxsize': 30, # 最大连接数设为30,避免超出数据库限制
|
||
'charset': 'utf8mb4',
|
||
"echo": False,
|
||
'pool_recycle': 3600, # 增加连接回收时间从300秒到3600秒(1小时)
|
||
'connect_timeout': 10, # 连接超时时间
|
||
}
|
||
},
|
||
},
|
||
'apps': {
|
||
'models': {
|
||
# 仅注册实际存在的模型模块,移除不存在的 apis.project.models,避免 Aerich 初始化失败
|
||
'models': [
|
||
"apis.country.models",
|
||
"aerich.models"
|
||
],
|
||
'default_connection': 'default',
|
||
|
||
}
|
||
},
|
||
'use_tz': False,
|
||
'timezone': 'Asia/Shanghai'
|
||
}
|