improve config: separate :connect-args

This commit is contained in:
Helmut Merz 2024-05-09 10:45:23 +02:00
parent 3f2fea6617
commit 3aacee896d
2 changed files with 13 additions and 10 deletions

View file

@ -46,11 +46,11 @@
(defun connect-sqlite (params config) (defun connect-sqlite (params config)
(declare (ignorable params)) (declare (ignorable params))
(print config) (print config)
(apply #'dbi:connect-cached (cons :sqlite3 config))) (apply #'dbi:connect-cached (cons :sqlite3 (getf config :connect-args))))
(defun connect-postgres (params config) (defun connect-postgres (params config)
(declare (ignorable params)) (declare (ignorable params))
(apply #'dbi:connect (cons :postgres config))) (apply #'dbi:connect (cons :postgres (getf config :connect-args))))
(defvar *db-params* (defvar *db-params*
'(:sqlite3 (:connect connect-sqlite '(:sqlite3 (:connect connect-sqlite

View file

@ -3,17 +3,20 @@
(defparameter db-config-sqlite (defparameter db-config-sqlite
'(:db-type :sqlite3 '(:db-type :sqlite3
:database-name "test/test.db" :connect-args
:busy-timeout 1)) (:database-name "test/test.db")
:options nil))
(defparameter db-config-postgres (defparameter db-config-postgres
'(:db-type :postgres '(:db-type :postgres
:database-name "cltest" :connect-args
(:database-name "cltest"
:host "localhost" :host "localhost"
:port 5432 :port 5432
:username "testuser" :username "testuser"
:password "secret" :password "secret")
:schema "testing")) :options
(:schema "testing")))
(setf scopes/test-storage:*db-config-sqlite* db-config-sqlite) (setf scopes/test-storage:*db-config-sqlite* db-config-sqlite)
(setf scopes/test-storage:*db-config-postgres* db-config-postgres) (setf scopes/test-storage:*db-config-postgres* db-config-postgres)