diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-07-27 16:16:45 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-07-27 16:16:45 +0100 |
commit | 6432f9a7465453bc2efa11b736e19d58a0503e43 (patch) | |
tree | 5f886a1b3713ec4b3b4d13be7d8753d947a9786f | |
parent | e55a5d135f7caa6f7921c1023fe8cab36b352c7b (diff) |
partially through writing code for commiting extracted data to the database
-rw-r--r-- | pkg/datamaps/db.go | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/pkg/datamaps/db.go b/pkg/datamaps/db.go index 76564dc..f1204a9 100644 --- a/pkg/datamaps/db.go +++ b/pkg/datamaps/db.go @@ -167,6 +167,35 @@ func importXLSXtoDB(dm_name string, return_name string, file string, db *sql.DB) return err } fmt.Printf("Extracting from %s\n", file) - fmt.Printf("Data is: %#v\n", d["Introduction"]["C17"].Value) + // fmt.Printf("Data is: %#v\n", d["Introduction"]["C17"].Value) + + stmtReturn, err := db.Prepare("insert into return(name, date_created) values(?,?)") + if err != nil { + log.Fatal(err) + } + + defer stmtReturn.Close() + + res, err := stmtReturn.Exec(return_name, time.Now()) + if err != nil { + log.Fatal(err) + } + + rId, err := res.LastInsertId() + if err != nil { + log.Fatal(err) + } + + // We're going to need a transaction for the big stuff + tx, err := db.Begin() + if err != nil { + return err + } + + stmtValues, err := tx.Prepare("INSERT INTO return_data (name, date_created) VALUES(?,?)") + if err != nil { + return err + } + return nil } |