forked from mtusi2026/mtusi2026lab3
lab3
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
|
||||
from psycopg.rows import dict_row
|
||||
from psycopg_pool import ConnectionPool
|
||||
|
||||
|
||||
def connection_kwargs():
|
||||
return {
|
||||
"host": os.getenv("POSTGRES_HOST", "postgres"),
|
||||
"port": int(os.getenv("POSTGRES_PORT", "5432")),
|
||||
"dbname": os.environ["POSTGRES_DB"],
|
||||
"user": os.environ["POSTGRES_USER"],
|
||||
"password": os.environ["POSTGRES_PASSWORD"],
|
||||
"connect_timeout": 5,
|
||||
"options": "-c statement_timeout=5000 -c lock_timeout=3000",
|
||||
"autocommit": True,
|
||||
"row_factory": dict_row,
|
||||
}
|
||||
|
||||
|
||||
pool = ConnectionPool(
|
||||
kwargs=connection_kwargs(),
|
||||
min_size=1,
|
||||
max_size=5,
|
||||
max_waiting=20,
|
||||
timeout=3,
|
||||
check=ConnectionPool.check_connection,
|
||||
open=False,
|
||||
)
|
||||
Reference in New Issue
Block a user