summaryrefslogtreecommitdiff
path: root/db/conn.rkt
diff options
context:
space:
mode:
Diffstat (limited to 'db/conn.rkt')
-rw-r--r--db/conn.rkt15
1 files changed, 10 insertions, 5 deletions
diff --git a/db/conn.rkt b/db/conn.rkt
index 42a75c0..11abc19 100644
--- a/db/conn.rkt
+++ b/db/conn.rkt
@@ -1,22 +1,27 @@
#lang racket
-(require db)
-
(provide current-conn
connect!
disconnect!
with-db
with-tx)
+(require db
+ "../debug.rkt")
+
(define current-conn (make-parameter #f))
(define (connect! #:path [path 'memory])
- (unless (connection? (current-conn))
- (current-conn (sqlite3-connect #:database path #:mode 'create))))
+ (if (connection? (current-conn))
+ (debug-log (format "Connection already instantiated: ~a" (current-conn)))
+ (begin
+ (current-conn (sqlite3-connect #:database path #:mode 'create))
+ (debug-log (format "Connection instantiated: ~a" (current-conn))))))
(define (disconnect!)
(disconnect (current-conn))
- (current-conn #f))
+ (current-conn #f)
+ (debug-log "Connection disconnected."))
(define-syntax-rule (with-db body ...)
(begin
Copyright 2019--2026 Marius PETER