How to log parameters instead of placeholders using sqlx with Postgres?

I'm using sqlx for the first time today.

I'm having really hard time understanding my SQL errors because I cannot copy & paste logged queries in my IDE because the parameters are not converted from placeholders.

It prints:

SELECT * from players where team_id = $1 AND id = $2

but I would like the below instead:

SELECT * from players where team_id = 'ABC' AND id = '123'

How to do this?

1 Like

You’ll have to log the parameters yourself and use them with PREPARE. sqlx never creates the query you’re trying to log - it uses parameterization as well, so the query you’re seeing logged really is the query sent to the DB.

1 Like