diff options
Diffstat (limited to 'db/connection.rkt')
-rw-r--r-- | db/connection.rkt | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/db/connection.rkt b/db/connection.rkt new file mode 100644 index 0000000..642ee35 --- /dev/null +++ b/db/connection.rkt @@ -0,0 +1,33 @@ +#lang typed/racket + +(provide current-connection + get-connection + set-connection! + connect) + +(require typed/db) + +(: current-connection (Parameterof (Option Connection))) +(define current-connection (make-parameter #f)) + +(define (get-connection) + (cond + [(current-connection) => identity] + [else (error "set-connection! でコネクションを設定してください")])) + +(: set-connection! (-> Connection Void)) +(define (set-connection! c) + (current-connection c)) + +(module untyped racket + (provide (rename-out [postgresql-connect connect])) + (require db)) + +(require/typed/provide (submod "." untyped) + [connect (->* (#:user String #:database String) + (#:server (Option String) + #:port Exact-Positive-Integer + #:socket (U 'guess Path-String False) + #:password (U String (List 'hash String) False) + #:allow-cleartext-password? (U 'local Boolean)) + Connection)]) |