Added export to csv

This commit is contained in:
Dmitry Lyukov
2016-03-27 02:14:30 +03:00
parent c9d59161d8
commit 77bd3bb48c

View File

@@ -241,21 +241,23 @@ func main() {
outputPath := flag.String("o", "", "Path to export file")
flag.Parse()
log.Println("keyboardId =", *keyboardId, "outputPath =", *outputPath)
// Opening database
db, err := sql.Open("sqlite3", DATABASE_NAME)
if err != nil {
log.Fatal(err)
}
db.SetMaxIdleConns(5)
db.SetMaxOpenConns(5)
defer db.Close()
keyMap := GetKeymap()
switch {
case *keyboardId == -1 && *outputPath == "":
flag.PrintDefaults()
return
case *keyboardId != -1:
// Opening database
db, err := sql.Open("sqlite3", DATABASE_NAME)
if err != nil {
log.Fatal(err)
}
db.SetMaxIdleConns(5)
db.SetMaxOpenConns(5)
defer db.Close()
keyMap := GetKeymap()
InitDb(db, keyMap)
@@ -295,6 +297,7 @@ func main() {
time.Sleep(SLEEP_TIME)
}
case *outputPath != "":
//exporting here
exportingData := GetStatTimesFromDb(db, 0, keyMap) //exporting here
SaveToCsvFile(exportingData, keyMap, *outputPath, false)
}
}