Commit ·
aba6b7f
1
Parent(s): 0391cfb
refactor: DB connection pool parameters
Browse files- postgre_mcp_server.py +8 -1
postgre_mcp_server.py
CHANGED
|
@@ -42,7 +42,14 @@ async def db_lifespan(server: FastMCP) -> AsyncIterator[DbContext]:
|
|
| 42 |
load_dotenv()
|
| 43 |
dsn = os.getenv("DB_URL")
|
| 44 |
schema = os.getenv("DB_SCHEMA")
|
| 45 |
-
pool = await asyncpg.create_pool(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
try:
|
| 47 |
yield DbContext(pool=pool, schema=schema)
|
| 48 |
finally:
|
|
|
|
| 42 |
load_dotenv()
|
| 43 |
dsn = os.getenv("DB_URL")
|
| 44 |
schema = os.getenv("DB_SCHEMA")
|
| 45 |
+
pool = await asyncpg.create_pool(
|
| 46 |
+
dsn,
|
| 47 |
+
min_size=1,
|
| 48 |
+
max_size=4,
|
| 49 |
+
max_inactive_connection_lifetime=300,
|
| 50 |
+
timeout=60,
|
| 51 |
+
command_timeout=300,
|
| 52 |
+
)
|
| 53 |
try:
|
| 54 |
yield DbContext(pool=pool, schema=schema)
|
| 55 |
finally:
|