Aasher commited on
Commit
d1f2042
·
1 Parent(s): 292a151

fix(db): update async engine configuration to use connection pool settings

Browse files
Files changed (1) hide show
  1. db/session.py +4 -3
db/session.py CHANGED
@@ -1,6 +1,5 @@
1
  from sqlmodel import SQLModel
2
  from sqlalchemy.ext.asyncio import create_async_engine
3
- from sqlalchemy.pool import NullPool
4
  from sqlmodel.ext.asyncio.session import AsyncSession
5
  from core.config import get_settings
6
 
@@ -10,8 +9,10 @@ async_engine = create_async_engine(
10
  settings.DATABASE_URL,
11
  echo=False,
12
  future=True,
13
- poolclass=NullPool,
14
- connect_args={"statement_cache_size": 0}
 
 
15
  )
16
 
17
  async def get_db():
 
1
  from sqlmodel import SQLModel
2
  from sqlalchemy.ext.asyncio import create_async_engine
 
3
  from sqlmodel.ext.asyncio.session import AsyncSession
4
  from core.config import get_settings
5
 
 
9
  settings.DATABASE_URL,
10
  echo=False,
11
  future=True,
12
+ pool_pre_ping=True,
13
+ pool_size=10, # The number of connections to keep open in the pool
14
+ max_overflow=5, # The number of connections to allow in "overflow"
15
+ pool_timeout=30, # How long to wait for a connection from the pool
16
  )
17
 
18
  async def get_db():