-
Notifications
You must be signed in to change notification settings - Fork 5
/
sql.go
51 lines (41 loc) · 1.1 KB
/
sql.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
package rdb
type sqlQueryHandler interface {
Query(string, ...interface{}) (Rows, error)
QueryRow(string, ...interface{}) Row
Get(dest interface{}, query string, args ...interface{}) error
Select(dest interface{}, query string, args ...interface{}) error
}
type sqlQueryExecuter interface {
Execute(string, ...interface{}) (Result, error)
NamedExecute(string, interface{}) (Result, error)
}
// SQLHandler knows how to run queries against itself
type SQLHandler interface {
sqlQueryHandler
sqlQueryExecuter
Begin() (TxHandler, error)
}
// TxHandler is a SQLHandler in a transaction context
type TxHandler interface {
sqlQueryHandler
sqlQueryExecuter
Commit() error
Rollback() error
}
// Result contains meta data of a query that was executed
type Result interface {
LastInsertID() (int64, error)
RowsAffected() (int64, error)
}
// Row contains the data from a query
type Row interface {
Scan(...interface{}) error
StructScan(interface{}) error
}
// Rows contains the data from a query
type Rows interface {
Scan(...interface{}) error
StructScan(interface{}) error
Next() bool
Close() error
}