[Chore/Refactor] db.session.xxx -> with Session as session #16246

Open
opened 2026-02-21 19:25:17 -05:00 by yindo · 6 comments
Owner

Originally created by @asukaminato0721 on GitHub (Aug 18, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for refactoring, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Description

db.session.commit() is Flask-SQLAlchemy

with Session(...) is Pure SQLAlchemy

Image

Motivation

for migration.

Additional Context

https://docs.sqlalchemy.org/en/20/orm/session_basics.html#framing-out-a-begin-commit-rollback-block

part of #23647

need https://github.com/facebook/pyrefly/issues/954

one example: #24135

Originally created by @asukaminato0721 on GitHub (Aug 18, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for refactoring, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Description db.session.commit() is Flask-SQLAlchemy with Session(...) is Pure SQLAlchemy <img width="519" height="253" alt="Image" src="https://github.com/user-attachments/assets/cfaa3fb9-92e1-406c-bcd9-e54d848b42be" /> ### Motivation for migration. ### Additional Context https://docs.sqlalchemy.org/en/20/orm/session_basics.html#framing-out-a-begin-commit-rollback-block part of #23647 need https://github.com/facebook/pyrefly/issues/954 one example: #24135
yindo added the good first issue label 2026-02-21 19:25:17 -05:00
Author
Owner

@liugddx commented on GitHub (Aug 18, 2025):

I will try

@liugddx commented on GitHub (Aug 18, 2025): I will try
Author
Owner

@laipz8200 commented on GitHub (Aug 18, 2025):

It seems this hasn't changed anything?

@laipz8200 commented on GitHub (Aug 18, 2025): It seems this hasn't changed anything?
Author
Owner

@asukaminato0721 commented on GitHub (Aug 18, 2025):

It seems this hasn't changed anything?

prepare for #24138

@asukaminato0721 commented on GitHub (Aug 18, 2025): > It seems this hasn't changed anything? prepare for #24138
Author
Owner

@ruanimal commented on GitHub (Sep 4, 2025):

why use Pure SQLAlchemy ?

@ruanimal commented on GitHub (Sep 4, 2025): why use Pure SQLAlchemy ?
Author
Owner

@asukaminato0721 commented on GitHub (Sep 23, 2025):

why use Pure SQLAlchemy ?

https://github.com/langgenius/dify/pull/10921#issuecomment-2490099306

@asukaminato0721 commented on GitHub (Sep 23, 2025): > why use Pure SQLAlchemy ? https://github.com/langgenius/dify/pull/10921#issuecomment-2490099306
Author
Owner

@asukaminato0721 commented on GitHub (Jan 21, 2026):

still some remaining places.

@asukaminato0721 commented on GitHub (Jan 21, 2026): still some remaining places.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#16246