-
Notifications
You must be signed in to change notification settings - Fork 111
/
sqlite.go
51 lines (40 loc) · 1017 Bytes
/
sqlite.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 sqlite
import (
"github.com/jmoiron/sqlx"
_ "modernc.org/sqlite"
"github.com/rilldata/rill/runtime/drivers"
)
func init() {
drivers.Register("sqlite", driver{})
}
type driver struct{}
func (d driver) Open(dsn string) (drivers.Connection, error) {
db, err := sqlx.Connect("sqlite", dsn)
if err != nil {
return nil, err
}
return &connection{db: db}, nil
}
type connection struct {
db *sqlx.DB
}
// Close implements drivers.Connection
func (c *connection) Close() error {
return c.db.Close()
}
// Registry implements drivers.Connection
func (c *connection) RegistryStore() (drivers.RegistryStore, bool) {
return c, true
}
// Catalog implements drivers.Connection
func (c *connection) CatalogStore() (drivers.CatalogStore, bool) {
return c, true
}
// Repo implements drivers.Connection
func (c *connection) RepoStore() (drivers.RepoStore, bool) {
return nil, false
}
// OLAP implements drivers.Connection
func (c *connection) OLAPStore() (drivers.OLAPStore, bool) {
return nil, false
}