2023-07-29 07:35:40 +00:00
|
|
|
from tortoise import Tortoise, run_async
|
2023-07-24 12:59:43 +00:00
|
|
|
|
|
|
|
from config.db_config import *
|
|
|
|
from tools import utils
|
|
|
|
|
|
|
|
|
|
|
|
async def init_db(create_db: bool = False) -> None:
|
|
|
|
await Tortoise.init(
|
|
|
|
db_url=RELATION_DB_URL,
|
|
|
|
modules={'models': ['models']},
|
2023-11-25 17:05:52 +00:00
|
|
|
# modules={'models': ['models.kuaishou']}, # generate special table
|
2023-07-24 12:59:43 +00:00
|
|
|
_create_db=create_db
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
async def init():
|
|
|
|
await init_db(create_db=True)
|
|
|
|
await Tortoise.generate_schemas()
|
|
|
|
utils.logger.info("Init DB Success!")
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
run_async(init())
|