You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
609 B
29 lines
609 B
"""
|
|
pip install aiomysql
|
|
"""
|
|
import logging
|
|
|
|
from aiomysql import create_pool
|
|
|
|
from Config.Config import *
|
|
|
|
# 配置日志
|
|
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# MySQL 配置
|
|
MYSQL_CONFIG = {
|
|
"host": MYSQL_HOST,
|
|
"port": MYSQL_PORT,
|
|
"user": MYSQL_USER,
|
|
"password": MYSQL_PASSWORD,
|
|
"db": MYSQL_DB_NAME,
|
|
"minsize": 1,
|
|
"maxsize": 20,
|
|
"charset": "utf8mb4"
|
|
}
|
|
|
|
|
|
# 初始化 MySQL 连接池
|
|
async def init_mysql_pool():
|
|
return await create_pool(**MYSQL_CONFIG) |