Public archive for the Return to Ritherdon project.
https://www.nicolaellisandritherdon.com
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
632 B
24 lines
632 B
2 years ago
|
(in-package :cl-user)
|
||
|
(defpackage ritherdon-archive.db
|
||
|
(:use :cl)
|
||
|
(:import-from :ritherdon-archive.config
|
||
|
:config)
|
||
|
(:import-from :datafly
|
||
|
:*connection*)
|
||
|
(:import-from :cl-dbi
|
||
|
:connect-cached)
|
||
|
(:export :connection-settings
|
||
|
:db
|
||
|
:with-connection))
|
||
|
(in-package :ritherdon-archive.db)
|
||
|
|
||
|
(defun connection-settings (&optional (db :maindb))
|
||
|
(cdr (assoc db (config :databases))))
|
||
|
|
||
|
(defun db (&optional (db :maindb))
|
||
|
(apply #'connect-cached (connection-settings db)))
|
||
|
|
||
|
(defmacro with-connection (conn &body body)
|
||
|
`(let ((*connection* ,conn))
|
||
|
,@body))
|