fullfill graphql usertype; change db session to dep injection

This commit is contained in:
2026-05-20 14:40:05 +08:00
parent f3b7fedade
commit b95cce592f
4 changed files with 47 additions and 14 deletions
+15 -2
View File
@@ -21,6 +21,19 @@ if not DATABASE_URL:
engine = create_engine(
DATABASE_URL,
pool_recycle=3600,
pool_pre_ping=True
pool_pre_ping=True,
connect_args={
"keepalives": 1,
"keepalives_idle": 30,
"keepalives_interval": 10,
"keepalives_count": 5
}
)
SessionLocal = sessionmaker(bind=engine)
SessionLocal = sessionmaker(bind=engine)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()