-
Notifications
You must be signed in to change notification settings - Fork 1
/
mysql.go
62 lines (62 loc) · 1.09 KB
/
mysql.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
//
//import (
// "bufio"
// "database/sql"
// _ "github.com/go-sql-driver/mysql"
// "fmt"
// "os"
// "time"
//)
//
//func main() {
// fmt.Println("test")
// db, err := sql.Open("mysql", "root:devOps!23@tcp(127.0.0.1:3306)/test")
// if err != nil {
// panic(err.Error())
// }
// defer db.Close()
//
// fmt.Println("db.Begin")
// tx, err := db.Begin()
// if err != nil {
// panic(err.Error())
// }
// defer tx.Rollback()
//
// reader := bufio.NewReader(os.Stdin)
// start := time.Now()
//
// fmt.Print("tx.Prepare: ")
// text, _ := reader.ReadString('\n')
// fmt.Println(text)
//
// stmt, err := tx.Prepare("SELECT no FROM test WHERE no=?")
// if err != nil {
// panic(err.Error())
// }
// defer stmt.Close()
// //
//
// fmt.Print("stmt.Exec: ")
// text, _ = reader.ReadString('\n')
// fmt.Println(text)
//
// _, err = stmt.Exec(2)
// if err != nil {
// panic(err.Error())
// }
//
// fmt.Print("tx.Commit: ")
// text, _ = reader.ReadString('\n')
// fmt.Println(text)
//
// err = tx.Commit()
// if err != nil {
// panic(err.Error())
// }
//
// end := time.Now()
// fmt.Println(end.Sub(start))
//
//}