You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ephraimbuddy (via GitHub)" <gi...@apache.org> on 2023/05/25 10:10:03 UTC

[GitHub] [airflow] ephraimbuddy commented on a diff in pull request #31486: Update code style for `airflow db` commands to SQLAlchemy 2.0 style

ephraimbuddy commented on code in PR #31486:
URL: https://github.com/apache/airflow/pull/31486#discussion_r1205298545


##########
airflow/utils/db.py:
##########
@@ -1633,8 +1641,9 @@ def resetdb(session: Session = NEW_SESSION, skip_init: bool = False):
     connection = settings.engine.connect()
 
     with create_global_lock(session=session, lock=DBLocks.MIGRATIONS):
-        drop_airflow_models(connection)
-        drop_airflow_moved_tables(session)
+        with connection.begin():

Review Comment:
   Yes. It's needed. The error says:
   ```log
   /opt/airflow/airflow/utils/db.py:1724 RemovedIn20Warning: The current statement is being autocommitted using implicit autocommit, which will be removed in SQLAlchemy 2.0. Use the .begin() method of Engine or Connection in order to use an explicit transaction for DML and DDL statements. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org