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

2

10

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?

Collazo answered 19/3, 2013 at 18:1 Comment(0)
G
12

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.
Gaylor answered 19/3, 2013 at 19:44 Comment(1)
Yep, that works with (insert ...) queries, so I'll accept it. I was trying to get (insert* ...) queries to do the same. But it's not strictly necessary since this works for (insert ...).Collazo
C
8

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

(println     
    (sql-only
        (select users)))
Carisa answered 1/1, 2014 at 15:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.