aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.md5
-rw-r--r--pkg/datamaps/db.go7
2 files changed, 10 insertions, 2 deletions
diff --git a/README.md b/README.md
index f0c37ba..a518938 100644
--- a/README.md
+++ b/README.md
@@ -16,3 +16,8 @@ CREATE TABLE return_data(id INTEGER PRIMARY KEY, dml_id INTEGER, value TEXT, FOR
datamap as dm inner join datamap_line as dml on dml.dm_id=dm.id inner join
return on return_data.ret_id=return.id inner join return_data on
return_data.ret_id=return.id;`
+
+### More accurate SQL to test all data at this stage:
+`select datamap.name, datamap_line.key, datamap_line.sheet, return.name,
+return_data.filename, return_data.value from datamap, datamap_line, return,
+return_data where datamap_line.dm_id=datamap.id;`
diff --git a/pkg/datamaps/db.go b/pkg/datamaps/db.go
index 416fc94..152ebc4 100644
--- a/pkg/datamaps/db.go
+++ b/pkg/datamaps/db.go
@@ -6,6 +6,7 @@ import (
"fmt"
"log"
"os"
+ "path"
"time"
// Needed for the sqlite3 driver
@@ -45,6 +46,7 @@ func setupDB(path string) (*sql.DB, error) {
id INTEGER PRIMARY KEY,
dml_id INTEGER,
ret_id INTEGER,
+ filename TEXT,
value TEXT,
FOREIGN KEY (dml_id)
REFERENCES datamap_line(id)
@@ -169,6 +171,7 @@ func DatamapToDB(opts *Options) error {
func importXLSXtoDB(dm_name string, return_name string, file string, db *sql.DB) error {
// d, err := ExtractDBDatamap(dm_name, file, db)
+ _, filename := path.Split(file)
d, err := ExtractDBDatamap(dm_name, file, db)
if err != nil {
return err
@@ -233,13 +236,13 @@ func importXLSXtoDB(dm_name string, return_name string, file string, db *sql.DB)
fmt.Println(err.Error())
}
- insertStmt, err := db.Prepare("insert into return_data (dml_id, ret_id, value) values(?,?,?)")
+ insertStmt, err := db.Prepare("insert into return_data (dml_id, ret_id, filename, value) values(?,?,?,?)")
if err != nil {
log.Fatal(err)
}
defer insertStmt.Close()
- _, err = insertStmt.Exec(dmlId, retId, cellData.Value)
+ _, err = insertStmt.Exec(dmlId, retId, filename, cellData.Value)
if err != nil {
log.Fatal(err)
}