python提交事务_事务提交和回滚
操作方法
begin; -開始事物
commit; - 提交事物? Python 默認是取消自動提交的
rollback; - 回撤操作, 只要操作沒有執行 commit 就可以進行回滾操作, 撤回
create table tb_account
(
accid char(4) not null,
uname varchar(20) not null,
balance float default 0
)
insert into tb_account values
('1111', '張明祿', 1200.99),
('2222', '王大錘', 500);
-- 開啟一個事物 ? start transaction
begin;
update tb_account set balance=balance-1000
where accid='1111';
update tb_account set balance=balance+1000
where accid='2222';
commit; ? -- 提交 才能改變
rollback; ?-- 撤銷
?
begin;
delete from? tb_account; ?-- 沒有commmit 不會刪除表
rollback;
---------------------
原文:https://blog.csdn.net/zhang_ming_lu/article/details/80835766
總結
以上是生活随笔為你收集整理的python提交事务_事务提交和回滚的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 由于没有远程桌面授权服务器可以提供许可证
- 下一篇: python环境变量配置步骤_关于人工智