feat: 实现MongoDB URI方式连接,并统一数据库连接代码。
This commit is contained in:
@@ -31,6 +31,7 @@ driver = get_driver()
|
||||
config = driver.config
|
||||
|
||||
Database.initialize(
|
||||
uri=config.MONGODB_URI,
|
||||
host=config.MONGODB_HOST,
|
||||
port=int(config.MONGODB_PORT),
|
||||
db_name=config.DATABASE_NAME,
|
||||
|
||||
@@ -37,14 +37,7 @@ def storage_compress_image(base64_data: str, max_size: int = 200) -> str:
|
||||
os.makedirs(images_dir, exist_ok=True)
|
||||
|
||||
# 连接数据库
|
||||
db = Database(
|
||||
host=config.mongodb_host,
|
||||
port=int(config.mongodb_port),
|
||||
db_name=config.database_name,
|
||||
username=config.mongodb_username,
|
||||
password=config.mongodb_password,
|
||||
auth_source=config.mongodb_auth_source
|
||||
)
|
||||
db = Database.get_instance()
|
||||
|
||||
# 检查是否已存在相同哈希值的图片
|
||||
collection = db.db['images']
|
||||
|
||||
Reference in New Issue
Block a user