I am trying to insert data in redshift from go. My query is
INSERT INTO wootric_nps.responses_updated (response_id,response_score,response_text,response_date,response_product) VALUES (?,?,?,?,?)
The parameters I am passing are [11 11 a a a] (they are of types int,int,string,string,string. This matches with the database schema)
When I execute the query, I get this issue:
syntax error at or near ","
The code for doing the whole thing is
insertbuilder := sq.Insert("wootric_nps.responses_updated").Columns("response_id", "response_score", "response_text", "response_date", "response_product")
a := 11
b := "a"
insertbuilder = insertbuilder.Values(a, a, b, b, b)
stmt, vals, err := insertbuilder.ToSql()
_, err = db.Exec(stmt, vals...)
if err != nil {
log.Println(err)
}
I have just used demo variables here.
Can someone point out what I am doing wrong in the query ?
Edit:
I got the solution. The placeholder for postgres is $, so the query should be ($1,$2,$3,$4,$5)