Atomicity , uniformity , Isolation , persistence
Start transaction manually :db.Begin()-->Tx
a set sql operation
tx.Exec(),tx.Prepare()...

Submit manually , RollBACK

tx.Commit(),tx.Rollback()

package main import ( "database/sql" "fmt" _ "github.com/go-sql-driver/mysql"
)func main() { /* affair : 4 Big features :ACID Atomicity : uniformity : Isolation : Permanence : */
//rose-->jack,2000 element db, _ := sql.Open("mysql",
"root:hanru1314@tcp(127.0.0.1:3306)/my1802?charset=utf8") // Open transaction tx, _ :=
db.Begin()// Provide a group sql operation var aff1, aff2 int64 = 0, 0 result1, _ := tx.Exec("UPDATE
account SET money=3000 WHERE id=?", 1) result2, _ := tx.Exec("UPDATE account
SET money2=2000 WHERE id=?", 2) //fmt.Println(result2) if result1 != nil { aff1,
_ = result1.RowsAffected() }if result2 != nil { aff2, _ = result2.RowsAffected()
; } fmt.Println(aff1) fmt.Println(aff2) if aff1 == 1 && aff2 == 1 { // Commit transaction
tx.Commit() fmt.Println(" The operation was successful ..") } else { // RollBACK tx.Rollback() fmt.Println(
" operation failed ... RollBACK ..") } }

Technology
©2019-2020 Toolsou All rights reserved,
QQ Login interface implementation code implementation mysql Addition, deletion, modification and query of database JAVA Experiment 4 set and functional programming experiment about String How to create objects VHDL——4 choose 1 Data selector C language ( Guess numbers games ) Blue Bridge Cup MCU advanced module --NE555 I don't memorize eight part essays , You go to the interview ? Hill sorting of sorting algorithm ——c++ realization python What does built-in function mean _python What are the built-in functions