Files
mokeeText/backend/config.py
2026-07-15 16:08:17 +08:00

21 lines
597 B
Python

"""数据库与应用配置"""
import os
# MySQL 数据库配置
DB_CONFIG = {
"user": os.getenv("MYSQL_USER", "mokeetext"),
"password": os.getenv("MYSQL_PASSWORD", "mokee."),
"host": os.getenv("MYSQL_HOST", "10.20.1.122"),
"port": int(os.getenv("MYSQL_PORT", "3306")),
"database": os.getenv("MYSQL_DATABASE", "mokeetext"),
}
def get_db_url():
"""构建数据库连接 URL"""
return (
f"mysql+pymysql://{DB_CONFIG['user']}:{DB_CONFIG['password']}"
f"@{DB_CONFIG['host']}:{DB_CONFIG['port']}/{DB_CONFIG['database']}"
f"?charset=utf8mb4"
)