1

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.

0 Answers0