- Description: A set of utilities to work with Postgresql using Mito and Common Lisp.
- Licence: Unlicense
- Author: Alexander Artemenko [email protected]
- Homepage: https://40ants.com/40ants-pg/
- Bug tracker: https://github.com/40ants/40ants-pg/issues
- Source control: GIT
- Depends on: alexandria, bordeaux-threads, cl-dbi, cl-mustache, dbd-postgres, dbi, ironclad, local-time, log4cl, mito, secret-values, serapeum, snakes, str, sxql
You can install this library from Quicklisp, but you want to receive updates quickly, then install it from Ultralisp.org:
(ql-dist:install-dist "http://dist.ultralisp.org/"
:prompt nil)
(ql:quickload :40ants-pg)
TODO
: Write a library description. Put some examples here.
package 40ants-pg/connection
condition 40ants-pg/connection:connection-error
(error)
Readers
reader 40ants-pg/connection:error-message
(connection-error) (:message)
function 40ants-pg/connection:connect
&key host database-name username password port (cached *cached-default*) (application-name nil) (use-ssl :no)
function 40ants-pg/connection:connect-toplevel
function 40ants-pg/connection:connect-toplevel-in-dev
macro 40ants-pg/connection:with-connection
(&rest connect-options) &body body
Establish a new connection and start transaction
package 40ants-pg/locks
condition 40ants-pg/locks:lock-timeout
(unable-to-aquire-lock)
Raised when you are trying to get lock to was unable to do this during current lock_timeout.
Readers
reader 40ants-pg/locks:lock-timeout
(lock-timeout) (:timeout)
condition 40ants-pg/locks:unable-to-aquire-lock
(simple-error)
Signaled if some thread was unable to get a lock on a database.
Readers
reader 40ants-pg/locks:lock-key
(unable-to-aquire-lock) (:key)
reader 40ants-pg/locks:lock-name
(unable-to-aquire-lock) (:lock-name)
macro 40ants-pg/locks:with-lock
(name &key (block t) (timeout 3) (signal-on-failure t)) &body body
package 40ants-pg/query
function 40ants-pg/query:all-objects-iterator
class &key (id-slot-getter #'object-id) (id-slot :id) (batch-size 10)
Iterates through all objects of given class fetching them in batches.
function 40ants-pg/query:execute
sql &rest params
function 40ants-pg/query:select-dao-by-ids
CLASS-NAME IDS &KEY (ID-FIELD "id") (ID-SLOT-GETTER #'OBJECT-ID) (SQL "SELECT * FROM {{table}} WHERE "{{column}}" in {{placeholders}}")
Returns CLOS
objects with given ids.
Results are returned in the same order as was in ids list. If some objects were not fetched, nil is returned at it's position in the resulting list.
function 40ants-pg/query:select-one-column
query &key binds (column :id)
function 40ants-pg/query:sql-fetch-all
sql &rest params
package 40ants-pg/settings
function 40ants-pg/settings:get-application-name
function 40ants-pg/settings:get-db-host
function 40ants-pg/settings:get-db-name
function 40ants-pg/settings:get-db-pass
function 40ants-pg/settings:get-db-port
function 40ants-pg/settings:get-db-user
function 40ants-pg/settings:get-default-application-name
package 40ants-pg/transactions
macro 40ants-pg/transactions:with-transaction
&body body
package 40ants-pg/utils
function 40ants-pg/utils:make-list-placeholders
list
Given a list of items, returns a string like "(?,?,?)" where number of questionmarks corresponds to number of list items.