/
sqlite.go
49 lines (40 loc) · 1.07 KB
/
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
package main
import (
"database/sql"
"log"
"github.com/FAU-CDI/drincw/internal/sparkl"
"github.com/FAU-CDI/drincw/internal/sparkl/exporter"
"github.com/FAU-CDI/drincw/internal/sparkl/storages"
"github.com/FAU-CDI/drincw/pathbuilder"
"github.com/FAU-CDI/drincw/pkg/perf"
_ "github.com/glebarez/go-sqlite"
_ "github.com/go-sql-driver/mysql"
)
const (
sqliteMaxQueryVar = 32766 // see https://www.sqlite.org/limits.html
sqlLiteBatchSize = 1000
)
func doSQL(pb *pathbuilder.Pathbuilder, index *sparkl.Index, bEngine storages.BundleEngine, proto, addr string) {
var err error
// setup the sqlite
db, err := sql.Open(proto, addr)
if err != nil {
log.Fatal(err)
}
// and do the export
{
start := perf.Now()
err = sparkl.Export(pb, index, bEngine, &exporter.SQL{
DB: db,
BatchSize: sqlLiteBatchSize,
MaxQueryVar: sqliteMaxQueryVar,
MakeFieldTables: sqlFieldTables,
Separator: sqlSeperator,
})
if err != nil {
log.Fatalf("Unable to export sql: %s", err)
}
bundleT := perf.Since(start)
log.Printf("wrote bundles, took %s", bundleT)
}
}