가장 눈에 띄는 차이점은 session.query()문의 사용이다.
2.0버전 부터는 select문과 함께 session.execute()문을 같이 사용하는 형태로 이를 대체한다.
session.query()문은 이제 레거시 API로 다음과 같은 warning이 표시된다.
SADeprecationWarning: Object <sqlalchemy.orm.query.Query object at 0x0000015A74CBDF90> should not be used directly in a SQL statement context, such as passing to methods such as session.execute().
This usage will be disallowed in a future release. Please use Core select() / update() / delete() etc. with Session.execute() and other statement execution methods.
이를 해결하기 위해 다음과 같은 예시들을 참고해서 코드를 변경해주면 된다.
참고 :
https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#migration-20-query-usage
SQLAlchemy 2.0 - Major Migration Guide — SQLAlchemy 2.0 Documentation
Previous: Changes and Migration Next: What’s New in SQLAlchemy 2.0? Up: Home On this page: SQLAlchemy 2.0 - Major Migration Guide The 1.4->2.0 Migration Path 1.x -> 2.x Migration Overview 2.0 Migration - Core Connection / Transaction 2.0 Migration - Core
docs.sqlalchemy.org
'메모' 카테고리의 다른 글
웹 컴포넌트(web component) (2) | 2023.04.26 |
---|---|
데이터베이스에서 글자 깨짐 현상 (0) | 2023.02.08 |
SQLAlchemy - back_populates (0) | 2023.01.30 |
POST axios로 application/x-www-form-urlencoded 보내는 법(node.js) (0) | 2023.01.30 |
Eclipse로 spring 프로젝트 만들기 창이 보이지 않을때 (0) | 2020.02.20 |