Skip to content

Commit 591e0aa

Browse files
niiish32xnishenghao.nsh
andauthored
fix(db): support async MySQL sessions by converting mysql+pymysql to mysql+asyncmy (#174)
Co-authored-by: nishenghao.nsh <nishenghao.nsh@oceanbase.com>
1 parent 36e1411 commit 591e0aa

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/derisk-core/src/derisk/storage/metadata/db_manager.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,12 @@ def init_db(
401401
if async_url.startswith("mysql+ob://"):
402402
# 替换为asyncmy驱动
403403
async_url = async_url.replace("mysql+ob://", "mysql+asyncmy://")
404+
elif async_url.startswith("mysql+pymysql://"):
405+
# 替换为asyncmy驱动(标准MySQL异步驱动)
406+
async_url = async_url.replace("mysql+pymysql://", "mysql+asyncmy://")
407+
elif async_url.startswith("mysql://"):
408+
# 纯mysql://也替换为asyncmy
409+
async_url = async_url.replace("mysql://", "mysql+asyncmy://")
404410
if async_url.startswith("sqlite"):
405411
# Don't upgrade memory db to async sqlite in tests, it fails with sync engine
406412
# unless we know for sure it's not a test using sync engine

0 commit comments

Comments
 (0)