设置数据库连接时区
Showing
2 changed files
with
5 additions
and
4 deletions
| ... | @@ -13,14 +13,15 @@ tortoise: | ... | @@ -13,14 +13,15 @@ tortoise: |
| 13 | minsize: 10 | 13 | minsize: 10 |
| 14 | maxsize: 200 | 14 | maxsize: 200 |
| 15 | connect_timeout: 30 | 15 | connect_timeout: 30 |
| 16 | echo: true | 16 | echo: true, |
| 17 | timezone: Asia/Shanghai | ||
| 17 | apps: | 18 | apps: |
| 18 | models_read: | 19 | models_read: |
| 19 | models: | 20 | models: |
| 20 | - app.model.mysql_model | 21 | - app.model.mysql_model |
| 21 | default_connection: default | 22 | default_connection: default |
| 22 | log_queries: true # 启用日志查询 | 23 | log_queries: true # 启用日志查询 |
| 23 | 24 | ||
| 24 | getSpider: | 25 | getSpider: |
| 25 | # 设置设置爬虫定时任务时间间隔 单位是分钟 | 26 | # 设置设置爬虫定时任务时间间隔 单位是分钟 |
| 26 | interval: 5 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 27 | interval: 5 | ... | ... |
| ... | @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) | ... | @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) |
| 12 | async def init(): | 12 | async def init(): |
| 13 | # 初始化链接 | 13 | # 初始化链接 |
| 14 | logger.info("开始初始化数据库") | 14 | logger.info("开始初始化数据库") |
| 15 | await Tortoise.init(config=getTortoiseConfig().dict()) | 15 | await Tortoise.init(config=getTortoiseConfig().model_dump()) |
| 16 | # 生成数据库表数据 | 16 | # 生成数据库表数据 |
| 17 | logger.info("开始生成数据库表") | 17 | logger.info("开始生成数据库表") |
| 18 | await Tortoise.generate_schemas() | 18 | await Tortoise.generate_schemas() | ... | ... |
-
Please register or sign in to post a comment