Implement feature extraction and inference enhancements, including async processing and MongoDB integration
This commit is contained in:
32
services/mongo.py
Normal file
32
services/mongo.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import datetime
|
||||
import os
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from bson import ObjectId
|
||||
from motor.motor_asyncio import (
|
||||
AsyncIOMotorClient,
|
||||
AsyncIOMotorCollection,
|
||||
AsyncIOMotorDatabase,
|
||||
)
|
||||
|
||||
MONGO_URI = os.getenv("MONGO_URI")
|
||||
|
||||
MongoQueryParam = int | str | None | bool | datetime.datetime
|
||||
|
||||
MongoQueryListParam = (
|
||||
List[int] | List[str] | List[datetime.datetime] | List[bool] | List[None]
|
||||
)
|
||||
|
||||
MongoQueryDictParam = Dict[
|
||||
str, MongoQueryListParam | MongoQueryParam | "MongoQueryDictParam"
|
||||
]
|
||||
|
||||
MongoQuery = Dict[
|
||||
str, MongoQueryDictParam | MongoQueryParam | MongoQueryListParam | "MongoQuery"
|
||||
]
|
||||
|
||||
# 明确的类型注解
|
||||
client: AsyncIOMotorClient = AsyncIOMotorClient(host=MONGO_URI)
|
||||
db: AsyncIOMotorDatabase = client["TriCore"]
|
||||
voice_collection: AsyncIOMotorCollection = db["voice_insight"]
|
||||
|
||||
Reference in New Issue
Block a user