load dotenv everywhere it's needed; postgresql pool pre ping

This commit is contained in:
2026-05-20 02:21:22 +08:00
parent c68d88b8c1
commit d54aeaa61a
7 changed files with 23 additions and 4 deletions
+5 -1
View File
@@ -18,5 +18,9 @@ elif DATABASE_URL and DATABASE_URL.startswith("postgres+"):
if not DATABASE_URL:
raise ValueError("DATABASE_URL environment variable is not set or empty.")
engine = create_engine(DATABASE_URL)
engine = create_engine(
DATABASE_URL,
pool_recycle=3600,
pool_pre_ping=True
)
SessionLocal = sessionmaker(bind=engine)