diff --git a/application/config/config.yaml b/application/config/config.yaml index 09a9fb78b4e7b927c5a08e717383d9b7a46a99f4..523689676e8a6a33dab7c3230e776502ed75354e 100644 --- a/application/config/config.yaml +++ b/application/config/config.yaml @@ -33,7 +33,7 @@ Logger: Retention: Scheduler: - Start: 2023-11-12 10:04:00 + Start: 2023-11-12 12:08:00 End: 2099-11-11 16:00:00 Timezone: Asia/Shanghai diff --git a/application/libs/helper/__init__.py b/application/libs/helper/__init__.py index c304e7b93b349722399ddef7016efb0dd9d3272a..dfea5b4b831ae3f65ce88d83c71595e897267fbe 100644 --- a/application/libs/helper/__init__.py +++ b/application/libs/helper/__init__.py @@ -13,3 +13,4 @@ from .config import ConfigHelper from .env import EnvVarHelper from .file import FileHelper +from .mysql import MySQLHelper diff --git a/application/libs/tasks/task.py b/application/libs/tasks/task.py index 58f3894941c2d045aa61a41c17d59e75adfdcbe9..14925c58e4f4c842b0f7b320ff79120b79960554 100644 --- a/application/libs/tasks/task.py +++ b/application/libs/tasks/task.py @@ -14,6 +14,7 @@ import datetime from application.extensions.init_sqlalchemy import db from application.models import User from application.common import global_config +from application.libs.helper import MySQLHelper def task(): @@ -23,9 +24,20 @@ def task(): :return: None """ with db.app.app_context(): - print("create user") - user = User(username="CWzz", email="Stuu@outlook.com", password="qwe!2345", active=True, - created_at=datetime.datetime.utcnow()) - user.save() - print(db.app.config) - print("created user admin") + cfg = db.app.config.ExtraDB + options = { + "host": cfg.Host, + "user": cfg.User, + "password": cfg.Password, + "database": cfg.DB, + "port": cfg.Port, + } + with MySQLHelper(**options) as helper: + print(helper.execute(cfg.Sql)) + print("create user") + # user = User(username="CWzz", email="Stuu@outlook.com", password="qwe!2345", active=True, + # created_at=datetime.datetime.utcnow()) + # user.save() + print(db.app.config) + + print("created user admin")