diff --git a/db.py b/db.py index 8ec4d5d..b1bc15e 100644 --- a/db.py +++ b/db.py @@ -18,6 +18,8 @@ async def init_db(create_db: bool = False) -> None: _create_db=create_db ) +async def close() -> None: + await Tortoise.close_connections() async def init(): await init_db(create_db=True) diff --git a/main.py b/main.py index 7c6a82b..73a1cfc 100644 --- a/main.py +++ b/main.py @@ -51,6 +51,9 @@ async def main(): crawler_type=args.type ) await crawler.start() + + if config.SAVE_DATA_OPTION == "db": + await db.close() if __name__ == '__main__':