I'm using SQLX and PQ to query an SQL database with PostGress. I'm using the function Select from SQLX with bindvars but PQ panics with
pq: got 1 parameters but the statement requires 0.
query = `
SELECT
count(*) AS count
FROM
ledger
WHERE
enterprise_id=($1)
`
var stat singleStat
err = db.Select(&stat, query, enterpriseID)
If anyone gets to here, I found out the answer by digging a bit on the pq source code. To use prepared parameters with Crate, it requires driver to send the parameters as binary before preparing the statement; answering with the types of the parameters.
To accomplish this, add 'binary_parameters=yes' to your connection string. Like:
"user=crate dbname=test binary_parameters=yes"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With