Knex: How to show sql?

Created on 12 Dec 2017  ·  3Comments  ·  Source: knex/knex

Questions about how to use knex

How to show sql on console when application running ?

Most helpful comment

http://knexjs.org/#Installation-debug

Run DEBUG=knex:query as environment variable.

Or use .toString() on a knex instance.

All 3 comments

http://knexjs.org/#Installation-debug

Run DEBUG=knex:query as environment variable.

Or use .toString() on a knex instance.

And toSQL().toNative() shows query in format that it is sent to sql driver. Also you can hook up printing to knex.on(’query’, ...) event

For the record, the documentation of this:

yourQuery.toSQL().toNative()

is here: http://knexjs.org/#Interfaces-toSQL

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aj0strow picture aj0strow  ·  3Comments

mtom55 picture mtom55  ·  3Comments

lanceschi picture lanceschi  ·  3Comments

legomind picture legomind  ·  3Comments

mattgrande picture mattgrande  ·  3Comments