I am getting an error when I try to use ? arguments when using the go sql library.
Whe I do something like:
_, err = db.Query(
`INSERT INTO user_account (username, password_hash) VALUES ("username", 'passwordhash');`,
everything works fine.
But when I do the following:
_, err = db.Query(
`INSERT INTO user_account (username, password_hash) VALUES (?, 'passwordhash');`,
`'username'`)
I get the error:
pq: syntax error at or near ","
How can I fix this error? I suspect it has something to do with the single quotes around the variables.
If it matters, I'm using postgreq with the pq driver.
usernameinstead of'username'? Theqppackage will escape the value by itself.INSERT INTO user_account (username, password_hash) VALUES (?, 'passwordhash');,"username")?but$1,$2, etc. Maybe try that.