Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to SQLAlchemy 2.0 #78

Open
wants to merge 149 commits into
base: master
Choose a base branch
from

Conversation

Daniel-Faber
Copy link
Contributor

@Daniel-Faber Daniel-Faber commented Dec 8, 2023

The used sqlalchemy.orm.mappers are deprecated in SQLAlchemy 2.0, alongside other breaking changes fixed in this PR.
Mainly we have to use sqlalchemy.orm.registry.map_imperatively instead of sqlalchemy.orm.mappers.
We can also re-use the mapper_registry to replace sqlalchemy.Metadata, see the docs: https://docs.sqlalchemy.org/en/20/orm/mapping_styles.html#imperative-mapping

Full Changelog fixing all breaking changes in SQLAlchemy 2.0:

  • Use sqlalchemy.sql.text when running sqlalchemy.orm.session.execute
  • Convert rows to dicts via row._asdict() instead of dict(r)
  • Use sqlalchemy.orm.registry.map_imperatively instead of sqlalchemy.orm.mappers
  • Optional: Use sqlalchemy.orm.registry.metadata instead of sqlalchemy.Metadata

hjwp added 30 commits February 23, 2021 16:37
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.

4 participants