-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql_test.go
45 lines (34 loc) · 843 Bytes
/
mysql_test.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
package goshard
import (
"fmt"
"testing"
)
func TestConnection(t *testing.T) {
c := &ConnectionParams{
Dbname: "events",
User: "mon",
Password: "!mon!",
QueryParams: "timeout=90s&collation=utf8mb4_unicode_ci&autocommit=true",
}
err, conn := NewConnection(c)
if err != nil {
fmt.Printf("ERROR!!: %s", err.Error())
return
}
defer conn.Close()
err, _ = conn.SelectRow("SELECT * FROM events ORDER BY id DESC limit 1")
if err != nil {
return
}
var r Row = make(Row)
r["id"] = "2"
err, _ = conn.InsertIgnore("test.unique_test", &r)
if err != nil {
return
}
var where_binds []interface{}
where_binds = append(where_binds, r["id"])
err, _ = conn.Update("test.unique_test", &Row{"create_date": "NOW()"}, "id=?", where_binds)
//conn.Delete("test.unique_test", "id=?", where_binds)
return
}