Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // digital ocean creds
- // db, err := sql.Open("mysql", "root:@/theory_mysql")
- databaseURL := os.Getenv("DATABASE_URL")
- fmt.Println(databaseURL)
- db, err := sql.Open("mysql", databaseURL)
- fmt.Println(databaseURL)
- if err != nil {
- fmt.Println("error opening theory database")
- }
- defer db.Close()
- // db, err := sql.Open("postgres", "user=q dbname=theory password=root45 sslmode=disable")
- // if err != nil {
- // fmt.Printf("Error connecting to postgres: %v\n", err)
- // }
- // fmt.Println("Successfully connected to the database")
- //check and make sure struct is populated
- // statement := `"insert into theory (address, city, email_address, first_name, last_name, profile_id, state, status, value, zipcode, type) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)"`, item.Address, item.City, item.EmailAddress, item.FirstName, item.LastName, item.ProfileID, item.State, item.Status, item.Value, item.Zipcode, item.Type
- // stmt, err := db.Prepare(statement)
- // if err != nil {
- // fmt.Printf("Error creating item %v\n", err)
- // return err
- // }
- fmt.Printf("StartTime: %v\n", time.Now())
- fmt.Println("Please do this")
- res, err := db.Exec("insert into transactions VALUES(?,?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", item.ID, item.PrintCode, item.FirstName, item.LastName, item.Address, item.City, item.State, item.Zipcode, item.EmailAddress, item.ProfileID, item.Status, item.Value, item.Type)
- // res, err := db.Exec("insert into theory VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)", item.Address, item.City, item.EmailAddress, item.FirstName, item.LastName, item.ProfileID, item.State, item.Status, item.Value, item.Zipcode, item.Type)
- if err != nil || res == nil {
- fmt.Printf("Error writing to database: %+v\n", err)
- }
- fmt.Println("RES from Query")
- fmt.Println(res)
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement