Created
March 28, 2017 06:53
-
-
Save gen1us2k/ad9ed783d4dac43cb55b58253e4056c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| res, err := conn.Exec("INSERT INTO users (name) VALUES(\"Peter\")") | |
| if err != nil { | |
| panic(err) | |
| } | |
| id, err := res.LastInsertId() | |
| if err != nil { | |
| panic(err) | |
| } | |
| fmt.Printf("Created user with id:%d", id) | |
| var user User | |
| err = conn.Get(&user, "select * from users where id=?", id) | |
| if err != nil { | |
| panic(err) | |
| } | |
| _, err = conn.Exec("UPDATE users set name=\"John\" where id=?", id) | |
| if err != nil { | |
| panic(err) | |
| } | |
| _, err = conn.Exec("DELETE FROM users where id=?", id) | |
| if err != nil { | |
| panic(err) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment