From 3d16c48e1796dd7f704c2614a2ec57a2309f33fa Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 4 Jun 2023 06:28:19 -0500 Subject: [PATCH] chore: Updates for SQLAlchemy 2.0 --- src/unihan_db/tables.py | 7 ++++--- tests/test_bootstrap.py | 6 ++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/unihan_db/tables.py b/src/unihan_db/tables.py index d93cd17e..f7d4bca5 100644 --- a/src/unihan_db/tables.py +++ b/src/unihan_db/tables.py @@ -23,10 +23,11 @@ """ from sqlalchemy import Boolean, Column, ForeignKey, Integer, String -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import relationship +from sqlalchemy.orm import DeclarativeBase, relationship -Base = declarative_base() + +class Base(DeclarativeBase): + pass class Unhn(Base): diff --git a/tests/test_bootstrap.py b/tests/test_bootstrap.py index 539662ad..ddb34ac2 100644 --- a/tests/test_bootstrap.py +++ b/tests/test_bootstrap.py @@ -16,14 +16,12 @@ def test_import_object(session, engine): def test_import_unihan(zip_file, session, engine, unihan_options): - Base.metadata.bind = engine - Base.metadata.create_all() + Base.metadata.create_all(bind=engine) # bootstrap.bootstrap_unihan(Base.metadata, unihan_options) def test_import_unihan_raw(zip_file, session, engine, unihan_options): - Base.metadata.bind = engine - Base.metadata.create_all() + Base.metadata.create_all(bind=engine) bootstrap.bootstrap_unihan(session, unihan_options)