summaryrefslogtreecommitdiff
path: root/db/conn.rkt
diff options
context:
space:
mode:
authorMarius Peter <dev@marius-peter.com>2025-11-29 13:45:29 +0100
committerMarius Peter <dev@marius-peter.com>2025-11-29 13:45:29 +0100
commit086ba55a15dc04914cba500f7ead61dec5490162 (patch)
treec2147f7f7d7802b43b44e90c37de802761a31b8c /db/conn.rkt
parentf54e5bda270d55a91f62be9cacbbcd1d3f1a0884 (diff)
Add debug facilities.
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