Skip to content

SQLAlchemy 2.0 migration of declarative_base #1593

@BrianJKoopman

Description

@BrianJKoopman

When running tests in socs I am seeing these warnings:

../../../../../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/sotodlib/io/g3thk_db.py:19
  /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/sotodlib/io/g3thk_db.py:19: 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)
    Base = declarative_base()

../../../../../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/sotodlib/io/g3tsmurf_db.py:9
  /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/sotodlib/io/g3tsmurf_db.py:9: 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)
    Base = declarative_base()

Per the SQLAlchemy 2.0 migration guide, declarative base moved from sqlalchemy.ext.declarative_base to sqlalchemy.orm.delcarative_base.

So I believe instances like this need to be updated with the new import path:

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, relationship, backref
Base = declarative_base()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions