Skip to content

Commit

Permalink
Add support for SQLAlchemy pool pre ping
Browse files Browse the repository at this point in the history
  • Loading branch information
Cinojose committed Sep 12, 2023
1 parent c29fc20 commit a4afbc4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/dispatch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ def __str__(self) -> str:
DATABASE_PORT = config("DATABASE_PORT", default="5432")
DATABASE_ENGINE_POOL_SIZE = config("DATABASE_ENGINE_POOL_SIZE", cast=int, default=20)
DATABASE_ENGINE_MAX_OVERFLOW = config("DATABASE_ENGINE_MAX_OVERFLOW", cast=int, default=0)
# Deal with DB disconnects
# https://docs.sqlalchemy.org/en/20/core/pooling.html#pool-disconnects
DATABASE_ENGINE_POOL_PING = config("DATABASE_ENGINE_POOL_PING", default=False)
SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{_DATABASE_CREDENTIAL_USER}:{_QUOTED_DATABASE_PASSWORD}@{DATABASE_HOSTNAME}:{DATABASE_PORT}/{DATABASE_NAME}"

ALEMBIC_CORE_REVISION_PATH = config(
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/database/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
config.SQLALCHEMY_DATABASE_URI,
pool_size=config.DATABASE_ENGINE_POOL_SIZE,
max_overflow=config.DATABASE_ENGINE_MAX_OVERFLOW,
pool_pre_ping=config.DATABASE_ENGINE_POOL_PING,
)


Expand Down

0 comments on commit a4afbc4

Please sign in to comment.