;; (in-package :cl-user) (defpackage hot-line.db (:use :cl) (:import-from :hot-line.config :config) (:import-from :datafly :*connection*) (:import-from :cl-dbi :connect-cached) (:export :connection-settings :db :with-connection)) (in-package :hot-line.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) ;; Added 'mito.connection:' to 'let' binding. To return to default, ;; just remove it so it just says '*connection*'. mito replaces ;; datafly. `(let ((mito.connection:*connection* ,conn)) ,@body))