diff options
author | Daniel Schadt <kingdread@gmx.de> | 2023-03-04 22:43:31 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2023-03-04 22:43:31 +0100 |
commit | 633934842b94d1ac70acaba0ef8ccb55cd44e816 (patch) | |
tree | 3276da87f75511112de348134f8e84bf1eab5e6d | |
parent | 249fec9d394e8c954bf26a0052a3f9d17ba38fab (diff) | |
download | fietsboek-633934842b94d1ac70acaba0ef8ccb55cd44e816.tar.gz fietsboek-633934842b94d1ac70acaba0ef8ccb55cd44e816.tar.bz2 fietsboek-633934842b94d1ac70acaba0ef8ccb55cd44e816.zip |
fix deprecated SQLAlchemy functions
Getting ready for SQLAlchemy 2.0!
-rw-r--r-- | fietsboek/models/meta.py | 2 | ||||
-rw-r--r-- | tests/conftest.py | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/fietsboek/models/meta.py b/fietsboek/models/meta.py index 6b11a09..f06c863 100644 --- a/fietsboek/models/meta.py +++ b/fietsboek/models/meta.py @@ -1,5 +1,5 @@ """Base metadata definition for the SQLAlchemy models.""" -from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import declarative_base from sqlalchemy.schema import MetaData # Recommended naming convention used by Alembic, as various different database diff --git a/tests/conftest.py b/tests/conftest.py index a203775..a499bec 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -59,9 +59,9 @@ def data_manager(app_settings): def _cleanup_data(app_settings): yield engine = models.get_engine(app_settings) - connection = engine.connect() - for table in reversed(Base.metadata.sorted_tables): - connection.execute(table.delete()) + with engine.begin() as connection: + for table in reversed(Base.metadata.sorted_tables): + connection.execute(table.delete()) data_dir = Path(app_settings["fietsboek.data_dir"]) if (data_dir / "tracks").is_dir(): shutil.rmtree(data_dir / "tracks") |