mirror of
https://github.com/NanmiCoder/MediaCrawler.git
synced 2026-06-06 18:07:26 +08:00
refactor: 数据存储重构,分离不同类型的存储实现
This commit is contained in:
10
db.py
10
db.py
@@ -1,14 +1,20 @@
|
||||
from typing import List
|
||||
|
||||
from tortoise import Tortoise, run_async
|
||||
|
||||
from config.db_config import *
|
||||
from tools import utils
|
||||
|
||||
|
||||
def get_platform_models() -> List[str]:
|
||||
models = ["store.xhs", "store.douyin", "store.bilibili", "store.kuaishou", "store.weibo"]
|
||||
return models
|
||||
|
||||
|
||||
async def init_db(create_db: bool = False) -> None:
|
||||
await Tortoise.init(
|
||||
db_url=RELATION_DB_URL,
|
||||
modules={'models': ['models']},
|
||||
# modules={'models': ['models.kuaishou']}, # generate special table
|
||||
modules={'models': get_platform_models()},
|
||||
_create_db=create_db
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user