https://github.com/40ants/40ants-pg
Utilities to simplify use of Postgresql in my Common Lisp projects
https://github.com/40ants/40ants-pg
commonlisp database utility
Last synced: 5 months ago
JSON representation
Utilities to simplify use of Postgresql in my Common Lisp projects
- Host: GitHub
- URL: https://github.com/40ants/40ants-pg
- Owner: 40ants
- Created: 2023-05-27T20:40:13.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2026-01-12T10:22:05.000Z (5 months ago)
- Last Synced: 2026-01-12T18:54:01.815Z (5 months ago)
- Topics: commonlisp, database, utility
- Language: Common Lisp
- Homepage: https://40ants.com/40ants-pg/
- Size: 134 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
Awesome Lists containing this project
README
# 40ants-pg - A set of utilities to work with Postgresql using Mito and Common Lisp.
## 40ANTS-PG ASDF System Details
* Description: A set of utilities to work with Postgresql using Mito and Common Lisp.
* Licence: Unlicense
* Author: Alexander Artemenko
* Homepage: [https://40ants.com/40ants-pg/][4ece]
* Bug tracker: [https://github.com/40ants/40ants-pg/issues][e36e]
* Source control: [GIT][5dfc]
* Depends on: [alexandria][8236], [bordeaux-threads][3dbf], [cl-dbi][6bc3], [cl-mustache][1dd0], [dbd-postgres][0b29], [dbi][a5c3], [ironclad][90b9], [local-time][46a1], [log4cl][7f8b], [mito][5b70], [secret-values][cd18], [serapeum][c41d], [snakes][165e], [str][ef7f], [sxql][2efd]
[][4232]

## Installation
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)
```
## Usage
`TODO`: Write a library description. Put some examples here.
## API
### 40ANTS-PG/CONNECTION
#### [package](0007) `40ants-pg/connection`
#### Classes
##### CONNECTION-ERROR
###### [condition](0c77) `40ants-pg/connection:connection-error` (error)
**Readers**
###### [reader](0c77) `40ants-pg/connection:error-message` (connection-error) (:message)
#### Functions
##### [function](26fc) `40ants-pg/connection:connect` &key host database-name username password port (cached \*cached-default\*) (application-name nil) (use-ssl :no)
##### [function](bcbe) `40ants-pg/connection:connect-toplevel`
##### [function](40c6) `40ants-pg/connection:connect-toplevel-in-dev`
#### Macros
##### [macro](800c) `40ants-pg/connection:with-connection` (&rest connect-options) &body body
Establish a new connection and start transaction
### 40ANTS-PG/LOCKS
#### [package](bf09) `40ants-pg/locks`
#### Classes
##### LOCK-TIMEOUT
###### [condition](1ba9) `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](1ba9) `40ants-pg/locks:lock-timeout` (lock-timeout) (:timeout)
##### UNABLE-TO-AQUIRE-LOCK
###### [condition](6c62) `40ants-pg/locks:unable-to-aquire-lock` (simple-error)
Signaled if some thread was unable to get a lock on a database.
**Readers**
###### [reader](6c62) `40ants-pg/locks:lock-key` (unable-to-aquire-lock) (:key)
###### [reader](6c62) `40ants-pg/locks:lock-name` (unable-to-aquire-lock) (:lock-name)
#### Macros
##### [macro](aef7) `40ants-pg/locks:with-lock` (name &key (block t) (timeout 3) (signal-on-failure t)) &body body
### 40ANTS-PG/QUERY
#### [package](17d9) `40ants-pg/query`
#### Functions
##### [function](94c1) `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](f55a) `40ants-pg/query:execute` sql &rest params
##### [function](b36b) `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](f490) `40ants-pg/query:select-one-column` query &key binds (column :id)
##### [function](ca01) `40ants-pg/query:sql-fetch-all` sql &rest params
### 40ANTS-PG/SETTINGS
#### [package](b194) `40ants-pg/settings`
#### Functions
##### [function](f7a9) `40ants-pg/settings:get-application-name`
##### [function](87b0) `40ants-pg/settings:get-db-host`
##### [function](54c5) `40ants-pg/settings:get-db-name`
##### [function](9d88) `40ants-pg/settings:get-db-pass`
##### [function](947a) `40ants-pg/settings:get-db-port`
##### [function](8f9c) `40ants-pg/settings:get-db-user`
##### [function](c891) `40ants-pg/settings:get-default-application-name`
### 40ANTS-PG/TRANSACTIONS
#### [package](4c1e) `40ants-pg/transactions`
#### Macros
##### [macro](b849) `40ants-pg/transactions:with-transaction` &body body
### 40ANTS-PG/UTILS
#### [package](cd52) `40ants-pg/utils`
#### Functions
##### [function](7f4f) `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.
##### [function](1cef) `40ants-pg/utils:map-by-id` dao-objects &key (id-slot-getter #'object-id) (test 'eql)
[4ece]: https://40ants.com/40ants-pg/
[5dfc]: https://github.com/40ants/40ants-pg
[4232]: https://github.com/40ants/40ants-pg/actions
[0007]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/connection.lisp#L1
[bcbe]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/connection.lisp#L120
[40c6]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/connection.lisp#L124
[800c]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/connection.lisp#L184
[0c77]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/connection.lisp#L49
[26fc]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/connection.lisp#L86
[bf09]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/locks.lisp#L1
[aef7]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/locks.lisp#L120
[6c62]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/locks.lisp#L47
[1ba9]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/locks.lisp#L64
[17d9]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/query.lisp#L1
[f490]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/query.lisp#L103
[94c1]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/query.lisp#L108
[f55a]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/query.lisp#L34
[ca01]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/query.lisp#L38
[b36b]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/query.lisp#L53
[b194]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/settings.lisp#L1
[87b0]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/settings.lisp#L18
[947a]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/settings.lisp#L22
[54c5]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/settings.lisp#L27
[8f9c]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/settings.lisp#L31
[9d88]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/settings.lisp#L35
[c891]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/settings.lisp#L40
[f7a9]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/settings.lisp#L45
[4c1e]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/transactions.lisp#L1
[b849]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/transactions.lisp#L19
[cd52]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/utils.lisp#L1
[1cef]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/utils.lisp#L13
[7f4f]: https://github.com/40ants/40ants-pg/blob/036e79ff65221db59fbdb5d30e2389855032ce43/src/utils.lisp#L23
[e36e]: https://github.com/40ants/40ants-pg/issues
[8236]: https://quickdocs.org/alexandria
[3dbf]: https://quickdocs.org/bordeaux-threads
[6bc3]: https://quickdocs.org/cl-dbi
[1dd0]: https://quickdocs.org/cl-mustache
[0b29]: https://quickdocs.org/dbd-postgres
[a5c3]: https://quickdocs.org/dbi
[90b9]: https://quickdocs.org/ironclad
[46a1]: https://quickdocs.org/local-time
[7f8b]: https://quickdocs.org/log4cl
[5b70]: https://quickdocs.org/mito
[cd18]: https://quickdocs.org/secret-values
[c41d]: https://quickdocs.org/serapeum
[165e]: https://quickdocs.org/snakes
[ef7f]: https://quickdocs.org/str
[2efd]: https://quickdocs.org/sxql
* * *
###### [generated by [40ANTS-DOC](https://40ants.com/doc/)]