hugsql

cjmurphy 2019-02-05T02:51:37.004200Z

Is there an example anywhere of using the function def-db-fns-from-string? It takes a string that is an sql statement. But how to specify the name of the function?? In a file I've used -- :name name-of-fn-so-can-call-it. Also presumably you don't put "\n"s in your string.

2019-02-05T03:46:54.005500Z

You can use multilined strings as is. No need to use \n

cjmurphy 2019-02-05T18:30:37.007500Z

But no harm either, it is just whitespace I guess. So you have -- :name <> before the sql statement and it will be recognised?

curtis.summers 2019-02-05T20:17:23.013Z

You can do that if you like. If you're looking to define hugsql statements from strings in a more granular manner, you might also look at db-fn, which will take a HugSQL-flavored SQL statement, a command (e.g. :?), and a result indicator (e.g. :*) and returns an anonymous function. So: (def my-func (hugsql/db-fn "select * from emp" :? :*)) Also, db-run has similar inline capabilities. http://layerware.github.io/hugsql/hugsql.core.html#var-db-fn http://layerware.github.io/hugsql/hugsql.core.html#var-db-run

cjmurphy 2019-02-05T20:18:55.014Z

Thanks @curtis.summers. That seems more like it. Worked. I just called my-func from your example, with the first arg being the map for the connection and the second arg being {} i.e. in the usual way.