aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/datamaps/db.go
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-07-23 17:02:27 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-07-23 17:02:27 +0100
commit4c8294bcbeb45ce93a74ad963a346cf69ccbc398 (patch)
treea26a6527a7ac15a6d37ba42102a83faec4098bd7 /pkg/datamaps/db.go
parent1cd5f295939e25e6af54bf69ae9f551f23c57f23 (diff)
working basics now with no flags package - thanks fzf
Diffstat (limited to 'pkg/datamaps/db.go')
-rw-r--r--pkg/datamaps/db.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/pkg/datamaps/db.go b/pkg/datamaps/db.go
index 0f6a930..527bbb6 100644
--- a/pkg/datamaps/db.go
+++ b/pkg/datamaps/db.go
@@ -55,10 +55,12 @@ func SetupDB(path string) (*sql.DB, error) {
//func DatafmapToDB(d_path string, data []DatamapLine, dm_name string, dm_path string) error {
func DatamapToDB(opts *Options) error {
fmt.Printf("Importing datamap file %s and naming it %s.\n", opts.DMPath, opts.DMName)
- // db, err := SetupDB("/home/lemon/.config/datamaps-go/datamaps.db")
- // if err != nil {
- // return err
- // }
+
+ data, err := ReadDML(opts.DMPath)
+ if err != nil {
+ log.Fatal(err)
+ }
+
d, err := sql.Open("sqlite3", opts.DBPath)
if err != nil {
return errors.New("Cannot open that damn database file")
@@ -85,7 +87,7 @@ func DatamapToDB(opts *Options) error {
}
defer stmt_dm.Close()
defer stmt_dml.Close()
- for _, dml := range opts.DMData {
+ for _, dml := range data {
_, err = stmt_dml.Exec(1, dml.Key, dml.Sheet, dml.Cellref)
if err != nil {
return err