-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (40 loc) · 981 Bytes
/
main.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
package main
import (
"crawshaw.io/sqlite/sqlitex"
sqle "github.com/dolthub/go-mysql-server"
"github.com/dolthub/go-mysql-server/auth"
"github.com/dolthub/go-mysql-server/server"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/information_schema"
"github.com/mergestat/go-mysql-sqlite-server/sqlitedb"
)
const (
dbName = "testdata/Chinook_Sqlite.sqlite"
)
func main() {
pool, err := sqlitex.Open(dbName, 0, 10)
if err != nil {
panic(err)
}
defer func() {
if err := pool.Close(); err != nil {
panic(err)
}
}()
db := sqlitedb.NewDatabase(dbName, pool, nil)
engine := sqle.NewDefault(
sql.NewDatabaseProvider(
db,
information_schema.NewInformationSchemaDatabase(),
))
config := server.Config{
Protocol: "tcp",
Address: "localhost:3306",
Auth: auth.NewNativeSingle("root", "", auth.AllPermissions),
}
s, err := server.NewDefaultServer(config, engine)
if err != nil {
panic(err)
}
s.Start()
}