20251222
This commit is contained in:
20
Server/app/core/database.py
Normal file
20
Server/app/core/database.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
数据库连接管理
|
||||
"""
|
||||
|
||||
import pymysql
|
||||
import os
|
||||
|
||||
def get_db_connection():
|
||||
"""获取数据库连接"""
|
||||
return pymysql.connect(
|
||||
host=os.getenv('DB_HOST', 'localhost'),
|
||||
port=int(os.getenv('DB_PORT', 3306)),
|
||||
user=os.getenv('DB_USER', 'root'),
|
||||
password=os.getenv('DB_PASSWORD', ''),
|
||||
database=os.getenv('DB_NAME', 'designercep'),
|
||||
charset='utf8mb4',
|
||||
cursorclass=pymysql.cursors.Cursor
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user