-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f16eff3
commit 0983067
Showing
6 changed files
with
48 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
import logging | ||
|
||
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine | ||
from sqlalchemy.pool import NullPool | ||
|
||
from src.core.config import _Env, settings | ||
from src.core.config import settings | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
if _Env.PROD.name == settings.ENV: | ||
async_engine = create_async_engine( | ||
url=settings.SQLALCHEMY_DATABASE_URI, | ||
pool_pre_ping=True, | ||
future=True, | ||
pool_size=settings.DATABASE_POOL_SIZE, | ||
connect_args={"server_settings": {"jit": "off"}}, | ||
max_overflow=settings.DATABASE_POOL_MAX_OVERFLOW, | ||
) | ||
else: | ||
# compatibility with pytest | ||
async_engine = create_async_engine( | ||
url=settings.SQLALCHEMY_DATABASE_URI, pool_pre_ping=True, future=True, poolclass=NullPool | ||
) | ||
async_engine = create_async_engine( | ||
url=settings.SQLALCHEMY_DATABASE_URI, | ||
pool_pre_ping=True, | ||
future=True, | ||
pool_size=settings.DATABASE_POOL_SIZE, | ||
connect_args={"server_settings": {"jit": "off"}}, | ||
max_overflow=settings.DATABASE_POOL_MAX_OVERFLOW, | ||
) | ||
async_session = async_sessionmaker(async_engine, autoflush=False, expire_on_commit=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters