Extract out opening PostgreSQL connections
So this can be reused.
This commit is contained in:
parent
470573b318
commit
1bdc8855ba
1 changed files with 7 additions and 2 deletions
|
|
@ -44,7 +44,7 @@
|
|||
(define pg-conn-finish
|
||||
(@@ (squee) pg-conn-finish))
|
||||
|
||||
(define* (with-postgresql-connection name f #:key (statement-timeout #f))
|
||||
(define (open-postgresql-connection name statement-timeout)
|
||||
(define paramstring
|
||||
(string-append
|
||||
(or (getenv "GUIX_DATA_SERVICE_DATABASE_PARAMSTRING")
|
||||
|
|
@ -62,8 +62,13 @@
|
|||
conn
|
||||
(simple-format #f "SET statement_timeout = ~A"
|
||||
statement-timeout)))
|
||||
|
||||
conn))
|
||||
|
||||
(define* (with-postgresql-connection name f #:key (statement-timeout #f))
|
||||
(let ((conn (open-postgresql-connection name statement-timeout)))
|
||||
(with-throw-handler
|
||||
#t
|
||||
#t
|
||||
(lambda ()
|
||||
(call-with-values
|
||||
(lambda ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue