-
Notifications
You must be signed in to change notification settings - Fork 1
/
if-db.go
39 lines (33 loc) · 1.05 KB
/
if-db.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
/*
© 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
ISC License
*/
package parl
import (
"context"
"database/sql"
)
type DB interface {
Exec(partition DBPartition, query string, ctx context.Context,
args ...any) (execResult ExecResult, err error)
Query(partition DBPartition, query string, ctx context.Context,
args ...any) (sqlRows *sql.Rows, err error)
QueryRow(partition DBPartition, query string, ctx context.Context,
args ...any) (sqlRow *sql.Row, err error)
QueryString(partition DBPartition, query string, ctx context.Context,
args ...any) (value string, err error)
QueryInt(partition DBPartition, query string, ctx context.Context,
args ...any) (value int, err error)
Close() (err error)
}
type ExecResult interface {
Get() (ID int64, rows int64)
String() (s string)
}
type DBPartition string
// DBFactory is a standardized way to obtain DB objects
type DBFactory interface {
NewDB(
dsnr DataSourceNamer,
schema func(dataSource DataSource, ctx context.Context) (err error)) (db DB)
}