-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
67 lines (43 loc) · 1.07 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2016 Shaybix. All Rights Reserved.
// A simple tool that converts MDB files to JSON
package main
import (
"flag"
"log"
"os"
"strings"
)
var format = flag.String("f", "json", "Choose either json or sql for format")
var dir = flag.String("d", "mdb", "Select the directory with the bok files")
var outputFile = flag.String("o", "db.sqlite", "Output file to dump your database content")
func init() {
flag.Parse()
}
func main() {
files := crawlDir("mdb")
for _, file := range files {
if file == "" {
continue
}
newFile := strings.Split(file, ".")[0]
dbFile := newFile + ".sqlite"
f, err := os.Create(dbFile)
defer f.Close()
if err != nil {
log.Fatalf("Could not create file: %v", err)
}
db, err := initDB(dbFile)
defer db.Close()
if err != nil {
log.Fatalf("could not initialise Sqlite database: %v", err)
}
err = schema(file, db)
if err != nil {
log.Printf("Not able to set the schema: %v", err)
}
err = dumpToSQL(file, db)
if err != nil {
log.Fatalf("Could not dump SQL to Database: %v", err)
}
}
}