Skip to content

fix: use non-deprecated sqlalchemy.orm.declarative_base import#106

Open
ayazhankadessova wants to merge 1 commit intosugarlabs:mainfrom
ayazhankadessova:fix/sqlalchemy-deprecation-warning
Open

fix: use non-deprecated sqlalchemy.orm.declarative_base import#106
ayazhankadessova wants to merge 1 commit intosugarlabs:mainfrom
ayazhankadessova:fix/sqlalchemy-deprecation-warning

Conversation

@ayazhankadessova
Copy link
Copy Markdown

Problem

Every import of app/database.py produces this deprecation warning:

MovedIn20Warning: The ``declarative_base()`` function is now available
as sqlalchemy.orm.declarative_base(). (deprecated since: 2.0)
(Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)

This shows up in server startup, test runs, and any script that touches the database models. The project uses SQLAlchemy 2.0.48 but still imports from the old 1.x path.

Fix

One-line import change:

-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.orm import sessionmaker, Session
+from sqlalchemy.orm import declarative_base, sessionmaker, Session

Verification

# With -W error (turns warnings into exceptions)
python -W error -c "from app.database import Base, APIKey; print('OK')"
# OK — no warnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant