-
Notifications
You must be signed in to change notification settings - Fork 2
/
conn_test.go
52 lines (42 loc) · 928 Bytes
/
conn_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
46
47
48
49
50
51
52
package sql2kv
import (
"testing"
)
func TestMySQL(t *testing.T) {
db := testMySQLDB
// Get lots of stuff from information_schema
_ = `select table_name from information_schema.columns limit 5`
rows, err := db.Queryx(`
select
TABLE_SCHEMA,
TABLE_NAME,
COLUMN_NAME,
DATA_TYPE
IS_NULLABLE,
COLUMN_KEY
from information_schema.columns where TABLE_SCHEMA='test'`)
if err != nil {
t.Error(err)
t.FailNow()
}
for rows.Next() {
// Probably need to model this explicitly
type InfoSchema struct {
Database string `db:"TABLE_SCHEMA"`
TableName string `db:"TABLE_NAME"`
ColumnName string `db:"COLUMN_NAME"`
DataType string `db:"DATA_TYPE"`
IsNullable string `db:"IS_NULLABLE"`
ColumnKey string `db:"COLUMN_KEY"`
}
_, err := rows.Columns()
if err != nil {
t.Error(err)
t.FailNow()
}
var is InfoSchema
if rows.StructScan(&is); err != nil {
t.Error(err)
}
}
}