Remove the no longer used engine and connection globals
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 1m52s

Only `session` is used in the package.
Bound to the `engine`, it connects on its first query
instead of when the package is imported.
This commit is contained in:
Alexander Hess 2026-11-30 14:03:05 +01:00
commit 2b112f46e2
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
2 changed files with 5 additions and 16 deletions

View file

@ -4,8 +4,6 @@ from velofy.db.addresses import Address
from velofy.db.addresses_addresses import Path
from velofy.db.addresses_pixels import AddressPixelAssociation
from velofy.db.cities import City
from velofy.db.connection import connection
from velofy.db.connection import engine
from velofy.db.connection import session
from velofy.db.couriers import Courier
from velofy.db.customers import Customer

View file

@ -1,9 +1,9 @@
"""Provide connection utils for the ORM layer.
This module defines fully configured `engine`, `connection`, and `session`
objects to be used as globals within the `velofy` package.
This module defines a fully configured `session` object
to be used as a global within the `velofy` package.
If a database is not guaranteed to be available, they are set to `None`.
If a database is not guaranteed to be available, it is set to `None`.
That is the case on the CI server.
"""
@ -11,19 +11,15 @@ import os
from typing import cast
import sqlalchemy as sa
from sqlalchemy import engine as engine_mod
from sqlalchemy import orm
import velofy
if os.getenv("TESTING"):
# Placeholders that the test fixtures replace
engine: engine_mod.Engine = None # type: ignore[assignment]
connection: engine_mod.Connection = None # type: ignore[assignment]
# Placeholder that the test fixtures replace
session: orm.Session = None # type: ignore[assignment]
else: # pragma: no cover
engine = sa.create_engine(cast(str, velofy.config.DATABASE_URI))
connection = engine.connect()
session = orm.sessionmaker(bind=connection)()
session = orm.Session(bind=engine)