package main import ( "flag" "log" "git.1750studios.com/ToddShepard/DB640/internal/csvparser" "git.1750studios.com/ToddShepard/DB640/internal/database" ) func main() { input := flag.String("i", "", "Specifies CSV input file") dialect := flag.String("d", "sqlite3", "Dialect for the database connection") connection := flag.String("c", "./csvfile.db", "Connection string for the database connection") flag.Parse() if *input == "" { log.Fatalf("Please specify the input file!") } err := database.Open(*dialect, *connection) if err != nil { log.Fatalf("Could not connect to database, error: %+v", err) } lines, err := csvparser.ParseFile(*input) if err != nil { log.Fatalf("Could not parse file, error: %+v", err) } for _, line := range lines { database.Db.Create(&database.Betriebsstelle{Code: line.Code, Name: line.Name}) log.Printf("Inserted %s with name %s into database!", line.Code, line.Name) } database.Close() }