entity.sql.hug

bind-connection

macro

(bind-connection conn sql-file options)
Bind a db connection returned from connect! to the collection
of functions defined in sql-file, leaving the map of values to
satisfy the query as the only parameter. If the connection is
held in a dynamic variable it can be bound for use within a
transaction.

Options should be a nested map of entity-opts, hug-opts
and jdbc-opts each of which is a map of options at that level.

Returns an implementation of entity-core/IO.

connect!

(connect! pool-spec)
Create a connection pool from the given pool-spec

disconnect!

(disconnect! conn)
Close the connection pool, if not already closed.

make-config

(make-config {:keys [jdbc-url adapter datasource datasource-classname], :as pool-spec})
Validate a pool specification and support some alternative spec keys

make-sql-fns

(make-sql-fns sql-file)(make-sql-fns sql-file entity-opts)(make-sql-fns sql-file entity-opts hug-opts)(make-sql-fns sql-file entity-opts hug-opts jdbc-opts)
Process a SQL file turning its functions into ready-made queries. The
file must include a snippet called select-stmt, which will be applied
in usages of all queries.

  - entity-opts will be merged with the supplied parameter values when
    the function is called. These additional values may be used by
    SQL statements and the select snippet as required, for example to
    support SQL implementation specific choices.

  - hug-opts will be passed to the HugSQL generated function.

  - jdbc-opts will be passed to the HugSQL generated function, which
    in turn passes them to the underlying JDBC library call.

with-transaction

macro

(with-transaction args & body)
Runs the body in a jdbc transaction using conn as the transaction connection.
The isolation level and readonly status of the transaction may also be specified.
(with-transaction [conn {:isolation level :read-only? true}]
  ... )
See clojure.java.jdbc/db-transaction* for more details on the transaction
options.