Files
dsProject/dsAiTeachingModel/utils/PostgreSQLUtil.py
2025-08-14 15:45:08 +08:00

22 lines
493 B
Python

"""
pip install asyncpg
"""
import asyncpg
from Config.Config import *
# PostgreSQL 配置
POSTGRES_CONFIG = {
"host": POSTGRES_HOST,
"port": POSTGRES_PORT,
"user": POSTGRES_USER,
"password": POSTGRES_PASSWORD,
"database": POSTGRES_DATABASE,
"min_size": 5, # 设置为0表示不保留空闲连接
"max_size": 20,
"command_timeout": 60
}
# 初始化 PostgreSQL 连接池
async def init_postgres_pool():
return await asyncpg.create_pool(**POSTGRES_CONFIG)