fix(db): update async engine configuration to use connection pool settings
Browse files- 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 |
-
|
14 |
-
|
|
|
|
|
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():
|