forked from apilayer/goiban-data-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.go
56 lines (48 loc) · 1.27 KB
/
loader.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
package main
import (
"database/sql"
"fmt"
"os"
"github.com/fourcube/goiban-data"
"github.com/fourcube/goiban-data-loader/loader"
_ "github.com/go-sql-driver/mysql"
)
var (
db *sql.DB
err error
bundesbankFile = "data/bundesbank.txt"
nbbFile = "data/nbb.xlsx"
netherlandsFile = "data/nl.xlsx"
luxembourgFile = "data/lu.xlsx"
switzerlandFile = "data/ch.xlsx"
austriaFile = "data/at.csv"
liechtensteinFile = "data/li.xlsx"
)
func main() {
if len(os.Args) < 3 {
fmt.Println("usage: goiban-data-loader <src> <dburl>")
fmt.Println("e.g: goiban-data-loader <bundesbank|nbb|nl|lu|at|ch|li> root:root@/goiban?charset=utf8")
return
}
target := os.Args[1]
connURL := os.Args[2]
repo := data.NewSQLStore("mysql", connURL)
switch target {
default:
fmt.Println("unknown target")
case "bundesbank":
loader.LoadBundesbankData(bundesbankFile, repo)
case "nbb":
loader.LoadBelgiumData(nbbFile, repo)
case "nl":
loader.LoadNetherlandsData(netherlandsFile, repo)
case "lu":
loader.LoadLuxembourgData(luxembourgFile, repo)
case "ch":
loader.LoadSwitzerlandData(switzerlandFile, repo)
case "li":
loader.LoadLiechtensteinData(liechtensteinFile, repo)
case "at":
loader.LoadAustriaData(austriaFile, repo)
}
}