korma.db

Functions for creating and managing database specifications.

*current-conn*

dynamic

*current-db*

dynamic

_default

c3p0-enabled?

connection-pool

(connection-pool {:keys [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 make-pool?], :or {host "localhost", port 3050, db "", make-pool? true}, :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 make-pool?], :or {db "h2.db", make-pool? true}, :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 make-pool?], :or {db "", make-pool? false}, :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 make-pool?], :or {user "dbuser", password "dbpassword", db "", host "localhost", port 1433, make-pool? true}, :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 make-pool?], :or {host "localhost", port 3306, db "", make-pool? true}, :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 make-pool?], :or {dsn "", make-pool? true}, :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 make-pool?], :or {host "localhost", port 1521, make-pool? true}, :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 make-pool?], :or {host "localhost", port 5432, db "", make-pool? true}, :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 make-pool?], :or {db "sqlite.db", make-pool? true}, :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 make-pool?], :or {host "localhost", port 5433, db "", make-pool? true}, :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