-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (41 loc) · 841 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
48
49
50
51
package main
import (
"database/sql"
"fmt"
"github.com/ancarebeca/expense-tracker/config"
"github.com/ancarebeca/expense-tracker/etl"
_ "github.com/go-sql-driver/mysql"
)
var path = "config/config.yaml"
func main() {
var db *sql.DB
conf := config.Conf{}
conf.LoadConfig(path)
callEtl(conf, db)
}
func callEtl(conf config.Conf, db *sql.DB) {
dataSourceName := fmt.Sprintf("%s:%s@/%s?charset=utf8", conf.UserDb, conf.PassDb, conf.Database)
db, _ = sql.Open("mysql", dataSourceName)
r := etl.CsvReader{}
repository := etl.RepositoryDb{
DB: db,
}
l := etl.LoadStatements{
&repository,
}
t := etl.DataTransformer{}
p := etl.SantanderParser{}
c := etl.Categorize{
Categories: make(map[string]string),
CategoryFile: conf.CategoryPath,
}
etl := etl.Etl{
conf,
&r,
&t,
&p,
&c,
&l,
}
etl.Run()
}