lib / pq

Pure Go Postgres driver for database/sql
https://pkg.go.dev/github.com/lib/pq
MIT License
9.01k stars 910 forks source link

pq: syntax error at or near "," #946

Closed Doca closed 4 years ago

Doca commented 4 years ago

Hello I'm struggeling with a very simple query. Maybe I didn't understand the concept or so but shouldnt this be possible with prepared statements? I get the error

pq: syntax error at or near ","

txn, err := db.Begin()
stmt, err := db.Prepare(`INSERT INTO advertiser_per_day (id,advertiser_name,additional,customer_id,site_id,tracking,counter,day,month,year) VALUES (?,?,?,?,?,?,?,?,?,?)`)

Is there a way to solve this with prepared statements?

johto commented 4 years ago

Is there a way to solve this with prepared statements?

Postgres doesn't use the inferior question mark syntax for parameters. See here.

Doca commented 4 years ago

Thanks a lot this works!