#lang racket/base (require (prefix-in db: (planet ryanc/db:1:5))) (define pgc (db:postgresql-connect #:user "ebus" #:database "ebus" #:password "ebus" #:server "10.2.2.26")) (define (query-sensor-id sensor-name) (db:query-value pgc "select id from sensor where name = $1" sensor-name)) (define (insert sensor-name value-float value-int value-string) (let ([sensor-id (query-sensor-id sensor-name)] [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))) ;(db:query-exec pgc "select