sqlalchemy的批量添加
bulk_save_objects
:速度中等,稳定高test_table
:需要添加的数据列表
User
:添加的实体对象
for k,v in enumerate(test_table):
session.bulk_save_objects(
[
User(rank=k+1)
]
)
session.commit()
sqlalchemy的批量修改
session.query(User).filter(User.district=='shandong').update({User.arrress: '中国'})
session.commit()
sqlalchemy的批量删除
session.query(User).filter(User.district=='shandong').delete()
session.commit()