aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/datamaps/db.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/datamaps/db.go (renamed from pkg/reader/db.go)16
1 files changed, 5 insertions, 11 deletions
diff --git a/pkg/reader/db.go b/pkg/datamaps/db.go
index 91b6b85..46d07bc 100644
--- a/pkg/reader/db.go
+++ b/pkg/datamaps/db.go
@@ -1,4 +1,4 @@
-package reader
+package datamaps
import (
"database/sql"
@@ -11,12 +11,6 @@ import (
_ "github.com/mattn/go-sqlite3"
)
-type Opts struct {
- DBPath, ImportPath, Name string
- Overwrite, Initial bool
- DMData []DatamapLine
-}
-
func SetupDB(path string) (*sql.DB, error) {
stmt_base := `DROP TABLE IF EXISTS datamap;
CREATE TABLE datamap(id INTEGER PRIMARY KEY, name TEXT, date_created TEXT);
@@ -58,9 +52,9 @@ func SetupDB(path string) (*sql.DB, error) {
// TODO - how do we avoid passing in all these params!??!
//DatamapToDB takes a slice of DatamapLine and writes it to a sqlite3 db file.
-//func DatamapToDB(d_path string, data []DatamapLine, dm_name string, dm_path string) error {
-func DatamapToDB(opts Opts) error {
- fmt.Printf("Importing datamap file %s and naming it %s.\n", opts.ImportPath, opts.Name)
+//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
@@ -83,7 +77,7 @@ func DatamapToDB(opts Opts) error {
if err != nil {
return err
}
- _, err = stmt_dm.Exec(opts.Name, time.Now())
+ _, err = stmt_dm.Exec(opts.DMName, time.Now())
stmt_dml, err := tx.Prepare("INSERT INTO datamap_line (dm_id, key, sheet, cellref) VALUES(?,?,?,?);")
if err != nil {