Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you make Korma output the SQL it would execute?

Tags:

clojure

korma

I'm trying to get Korma to output the SQL it would execute so I can debug a problem I'm having, but the docs are very terse on how to use the as-sql function. Can anyone give me an example of how to make Korma output the SQL for an INSERT query?

like image 212
cap10morgan Avatar asked Mar 19 '13 18:03

cap10morgan


2 Answers

from: http://sqlkorma.com/api/0.3.0/korma.core.html

dry-run
(dry-run & body)
Wrap around a set of queries to print to the console all SQL that would 
be run and return dummy values instead of executing them.
like image 150
Arthur Ulfeldt Avatar answered Oct 31 '22 22:10

Arthur Ulfeldt


If you want to get the SQL query as a string, there is also sql-only

(println     
    (sql-only
        (select users)))
like image 8
shock_one Avatar answered Oct 31 '22 22:10

shock_one