📜  替换 sqlalchemy - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:33.390000             🧑  作者: Mango

代码示例1
updated_rows = (
    session.query(YourTable)
    .filter(YourTable.your_field.like('%est%'))
    .update({YourTable.your_field: func.replace(YourTable.your_field, 'from_str', 'to_str')},
            synchronize_session=False)
    )
print("Updated {} rows".format(updated_rows))