-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathmain.go
41 lines (33 loc) · 845 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
package main
import (
"database/sql"
"log"
_ "github.com/go-sql-driver/mysql"
"github.com/hgfischer/mysqlsuperdump/dumper"
)
func main() {
checkError := func(err error) {
if err != nil {
log.Fatal(err)
}
}
cfg := newConfig()
checkError(cfg.parseAll())
verbosely := cfg.getVerboseLogger()
verbosely.Println("Connecting to MySQL database at", cfg.dsn)
db, err := sql.Open("mysql", cfg.dsn)
db.SetMaxOpenConns(cfg.maxOpenConns)
checkError(err)
defer db.Close()
dumpr := dumper.NewMySQLDumper(db, verbosely)
dumpr.SelectMap = cfg.selectMap
dumpr.WhereMap = cfg.whereMap
dumpr.FilterMap = cfg.filterMap
dumpr.UseTableLock = cfg.useTableLock
dumpr.ExtendedInsertRows = cfg.extendedInsRows
w, err := cfg.initOutput()
checkError(err)
defer w.Close()
verbosely.Println("Starting dump")
checkError(dumpr.Dump(w))
}