start_transaction¶
- AsyncDeepModel.start_transaction(flatten=False)¶
开启事务
上下文管理器,使用with语法开启上下文,上下文中的ql将作为事务执行 退出with语句块后,事务将立即执行,执行过程中如果报错会直接抛出
示例
import pandas as pd dm = DeepModel() data = pd.DataFrame( { 'name': ['Alice', 'Bob', 'Carol'], 'deck': [ "Dragon", "Golem", "Imp" ], 'awards': [ "1st", "2nd", "3rd" ], } ) async with dm.start_transaction(): await dm.execute("delete User") await dm.insert_df("User", data)