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.
22 lines
514 B
22 lines
514 B
"""
|
|
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": 1, # 设置为0表示不保留空闲连接
|
|
"max_size": 20,
|
|
"command_timeout": 60
|
|
}
|
|
|
|
# 初始化 PostgreSQL 连接池
|
|
async def init_postgres_pool():
|
|
return await asyncpg.create_pool(**POSTGRES_CONFIG) |