Try to adapt the PostgreSQL paramstring to use with sqitch
This commit is contained in:
parent
673d762e68
commit
0dc05982cd
2 changed files with 47 additions and 11 deletions
|
|
@ -21,7 +21,9 @@
|
|||
#:use-module (ice-9 threads)
|
||||
#:use-module (squee)
|
||||
#:use-module (guix-data-service config)
|
||||
#:export (with-postgresql-connection
|
||||
#:export (get-database-config
|
||||
|
||||
with-postgresql-connection
|
||||
|
||||
with-postgresql-connection-per-thread
|
||||
with-thread-postgresql-connection
|
||||
|
|
@ -39,6 +41,22 @@
|
|||
(define pg-conn-finish
|
||||
(@@ (squee) pg-conn-finish))
|
||||
|
||||
(define (paramstring->alist s)
|
||||
(map
|
||||
(lambda (param)
|
||||
(match (string-split param #\=)
|
||||
((key val)
|
||||
(cons key val))))
|
||||
(string-split s #\space)))
|
||||
|
||||
(define (get-database-config)
|
||||
(let ((paramstring (getenv "GUIX_DATA_SERVICE_DATABASE_PARAMSTRING")))
|
||||
(if paramstring
|
||||
(paramstring->alist paramstring)
|
||||
`(("dbname" . ,(%config 'database-name))
|
||||
("user" . ,(%config 'database-user))
|
||||
("host" . ,(%config 'database-host))))))
|
||||
|
||||
(define (open-postgresql-connection name statement-timeout)
|
||||
(define paramstring
|
||||
(string-append
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue