Skip to content

Commit

Permalink
add sqlalchemy application name
Browse files Browse the repository at this point in the history
  • Loading branch information
OriHoch committed Oct 30, 2024
1 parent ec8650f commit 058e5c9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion open_bus_stride_db/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@
from sqlalchemy.orm import sessionmaker, Session


SQLALCHEMY_APPLICATION_NAME = os.getenv("SQLALCHEMY_APPLICATION_NAME", "db")
SQLALCHEMY_APPLICATION_VERSION = os.getenv("SQLALCHEMY_APPLICATION_VERSION", "-")


engine = create_engine(
os.environ.get('SQLALCHEMY_URL', 'postgresql://postgres:123456@localhost'),
future=True,
connect_args={"options": "-c timezone=utc"},
connect_args={
"options": "-c timezone=utc",
"application_name": f'{SQLALCHEMY_APPLICATION_NAME} {SQLALCHEMY_APPLICATION_VERSION}'[:64],
},
echo=bool(os.environ.get('SQLALCHEMY_ECHO')),
pool_size=int(os.environ.get('SQLALCHEMY_POOL_SIZE', 10)),
max_overflow=int(os.environ.get('SQLALCHEMY_MAX_OVERFLOW', 20)),
Expand Down

0 comments on commit 058e5c9

Please sign in to comment.