Sqlx: How to print sql ?

Created on 30 Jul 2018  路  4Comments  路  Source: jmoiron/sqlx

db.Exec(query,args...)

can the sqlx engine print the query sentence like db.PrintSQL(true)?

Most helpful comment

Please it is necessary to consider enabling logging. We don't have to tamper with our database servers to see logs as developers

All 4 comments

You can turn on logging in your SQL server. Afaik almost any SQL derivate supports this feature.

I would echo @juliusmh's comment. In PostgreSQL you can enable SQL statement logging:

SHOW log_statement;

ALTER DATABASE mydb
  SET log_statement = 'all';

-- restart postgres
SHOW log_statement;

ALTER DATABASE mydb
  SET log_statement = 'none';

Or, by editing postgresql.conf and changing the log_statement setting to 'all'.

https://www.postgresql.org/docs/9.5/static/runtime-config-logging.html

Please it is necessary to consider enabling logging. We don't have to tamper with our database servers to see logs as developers

Well,not supported.

Was this page helpful?
0 / 5 - 0 ratings