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?

2 Likes

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.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.