init: 汽车零部件智能报价 MCP 服务(ERP + CRM)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
"""PostgreSQL 连接池管理"""
|
||||
|
||||
import asyncpg
|
||||
import os
|
||||
|
||||
DB_CONFIG = {
|
||||
"host": os.getenv("ERP_DB_HOST", "192.168.1.206"),
|
||||
"port": int(os.getenv("ERP_DB_PORT", "5432")),
|
||||
"user": os.getenv("ERP_DB_USER", "postgres"),
|
||||
"password": os.getenv("ERP_DB_PASSWORD", "digiwin"),
|
||||
"database": os.getenv("ERP_DB_NAME", "smart_quotation_auto"),
|
||||
}
|
||||
|
||||
_pool: asyncpg.Pool | None = None
|
||||
|
||||
|
||||
async def get_pool() -> asyncpg.Pool:
|
||||
global _pool
|
||||
if _pool is None:
|
||||
_pool = await asyncpg.create_pool(**DB_CONFIG, min_size=2, max_size=10)
|
||||
return _pool
|
||||
|
||||
|
||||
async def close_pool():
|
||||
global _pool
|
||||
if _pool:
|
||||
await _pool.close()
|
||||
_pool = None
|
||||
Reference in New Issue
Block a user