summaryrefslogtreecommitdiff
path: root/ebus-racket/db.rkt
diff options
context:
space:
mode:
Diffstat (limited to 'ebus-racket/db.rkt')
-rw-r--r--ebus-racket/db.rkt21
1 files changed, 12 insertions, 9 deletions
diff --git a/ebus-racket/db.rkt b/ebus-racket/db.rkt
index 14817e5..9ebdfa9 100644
--- a/ebus-racket/db.rkt
+++ b/ebus-racket/db.rkt
@@ -22,16 +22,19 @@
;; Get ID of sensor given by sensor-name
;; define sensor if needed
(define (sensor-id sensor-name)
- (let ([id (get-sensor-id sensor-name)])
- (cond ((void? id) (create-sensor-id sensor-id))
- (else id))))
+ (define id (get-sensor-id sensor-name))
+ (cond ((void? id) (create-sensor-id sensor-id))
+ (else id)))
(define (insert sensor-name value-float value-int value-string)
- (let ([sensor-id (sensor-id sensor-name)]
- [type (cond ((not (void? value-string)) "string")
+ (define sensor-id (sensor-id sensor-name))
+ (define type (cond ((not (void? value-string)) "string")
((not (void? value-float)) "float")
- ((not (void? value-int)) "int"))])
- (db:query-exec (string-append "INSERT INTO value(timestamp, sensor_id, type, value_float, value_int, value_string) "
- "VALUES (now(), $1, $2, $3, $4, $5)")
- sensor-id type value-float value-int value-string)))
+ ((not (void? value-int)) "int")))
+ (db:query-exec (string-append "INSERT INTO value(timestamp, sensor_id, type, value_float, value_int, value_string) "
+ "VALUES (now(), $1, $2, $3, $4, $5)")
+ sensor-id type value-float value-int value-string))
+
+(provide
+ (prefix-out db- insert))