korma.db
Functions for creating and managing database specifications.
connection-pool
(connection-pool {:keys [connection-uri subprotocol subname classname excess-timeout idle-timeout initial-pool-size minimum-pool-size maximum-pool-size test-connection-query idle-connection-test-period test-connection-on-checkin test-connection-on-checkout], :or {maximum-pool-size 15, idle-timeout (* 3 60 60), excess-timeout (* 30 60), idle-connection-test-period 0, test-connection-query nil, test-connection-on-checkin false, test-connection-on-checkout false, initial-pool-size 3, minimum-pool-size 3}, :as spec})
Create a connection pool for the given database spec.
create-db
(create-db spec)
Create a db connection object manually instead of using defdb. This is often
useful for creating connections dynamically, and probably should be followed
up with:
(default-connection my-new-conn)
If the spec includes `:make-pool? true` makes a connection pool from the spec.
default-connection
(default-connection conn)
Set the database connection that Korma should use by default when no
alternative is specified.
defdb
macro
(defdb db-name spec)
Define a database specification. The last evaluated defdb will be used by
default for all queries where no database is specified by the entity.
delay-pool
(delay-pool spec)
Return a delay for creating a connection pool for the given spec.
do-query
(do-query {:keys [db], :as query})
firebird
(firebird {:keys [host port db], :or {host "localhost", port 3050, db ""}, :as opts})
Create a database specification for a FirebirdSQL database. Opts should include
keys for :db, :user, :password. You can also optionally set host, port and make-pool?
get-connection
(get-connection db)
Get a connection from the potentially delayed connection object.
h2
(h2 {:keys [db], :or {db "h2.db"}, :as opts})
Create a database specification for a h2 database. Opts should include a key
for :db which is the path to the database file.
is-rollback?
(is-rollback?)
Returns true if the current transaction will be rolled back
msaccess
(msaccess {:keys [db], :or {db ""}, :as opts})
Create a database specification for a Microsoft Access database. Opts
should include keys for :db and optionally :make-pool?.
mssql
(mssql {:keys [user password db host port], :or {user "dbuser", password "dbpassword", db "", host "localhost", port 1433}, :as opts})
Create a database specification for a mssql database. Opts should include keys
for :db, :user, and :password. You can also optionally set host and port.
mysql
(mysql {:keys [host port db], :or {host "localhost", port 3306, db ""}, :as opts})
Create a database specification for a mysql database. Opts should include keys
for :db, :user, and :password. You can also optionally set host and port.
Delimiters are automatically set to "`".
odbc
(odbc {:keys [dsn], :or {dsn ""}, :as opts})
Create a database specification for an ODBC DSN. Opts
should include keys for :dsn and optionally :make-pool?.
oracle
(oracle {:keys [host port], :or {host "localhost", port 1521}, :as opts})
Create a database specification for an Oracle database. Opts should include keys
for :user and :password. You can also optionally set host and port.
postgres
(postgres {:keys [host port db], :or {host "localhost", port 5432, db ""}, :as opts})
Create a database specification for a postgres database. Opts should include
keys for :db, :user, and :password. You can also optionally set host and
port.
resolve-new
macro
(resolve-new class)
rollback
(rollback)
Tell this current transaction to rollback.
sqlite3
(sqlite3 {:keys [db], :or {db "sqlite.db"}, :as opts})
Create a database specification for a SQLite3 database. Opts should include a
key for :db which is the path to the database file.
transaction
macro
(transaction body)
(transaction options & body)
Execute all queries within the body in a single transaction.
Optionally takes as a first argument a map to specify the :isolation and :read-only? properties of the transaction.
vertica
(vertica {:keys [host port db], :or {host "localhost", port 5433, db ""}, :as opts})
Create a database specification for a vertica database. Opts should include keys
for :db, :user, and :password. You can also optionally set host and port.
Delimiters are automatically set to "`".
with-db
macro
(with-db db & body)
Execute all queries within the body using the given db spec