diff --git a/sevenkeys/main.go b/sevenkeys/main.go index 886d859..324a629 100644 --- a/sevenkeys/main.go +++ b/sevenkeys/main.go @@ -2,7 +2,9 @@ package main import ( "database/sql" + "encoding/json" "io" + "io/ioutil" "log" "net/http" "os" @@ -157,6 +159,17 @@ func main() { log.Printf("Bulk data has not been updated. Skipping download.") } - // Unmarshal cached file into Golang struct - // Import cards into database + log.Printf("Unmarsaling file into slice...") + allCardsBytes, err := ioutil.ReadFile(ALL_CARDS_CACHE_FILENAME) + check(err) + + var allCards []types.Card + err = json.Unmarshal(allCardsBytes, &allCards) + check(err) + log.Printf("Unmarshaled file.") + + log.Printf("Importing card data into database...") + err = operations.InsertCards(db, allCards) + check(err) + log.Printf("Imported card data.") }