25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
(let ((keys '())) ;; keys are vectors <fieldname,type>
(sqlite3:for-each-row (lambda (fieldname fieldtype)
(set! keys (cons (vector fieldname fieldtype) keys)))
db
"SELECT fieldname,fieldtype FROM keys ORDER BY id ASC;")
(reverse keys))) ;; could just sort desc?
;; get key vals for a given run-id
(define (get-key-vals db run-id)
(let* ((keys (get-keys db))
(res '()))
(debug:print 6 "keys: " keys " run-id: " run-id)
(for-each
(lambda (key)
(let ((qry (conc "SELECT " (key:get-fieldname key) " FROM runs WHERE id=?;")))
;; (debug:print 0 "qry: " qry)
(sqlite3:for-each-row
(lambda (key-val)
(set! res (cons key-val res)))
db qry run-id)))
keys)
(reverse res)))
;; get key val pairs for a given run-id
;; ( (FIELDNAME1 keyval1) (FIELDNAME2 keyval2) ... )
(define (keys:get-key-val-pairs db run-id)
(let* ((keys (get-keys db))
(res '()))
(debug:print 6 "keys: " keys " run-id: " run-id)
(for-each
(lambda (key)
(let ((qry (conc "SELECT " (key:get-fieldname key) " FROM runs WHERE id=?;")))
;; (debug:print 0 "qry: " qry)
(sqlite3:for-each-row
(lambda (key-val)
(set! res (cons (list (key:get-fieldname key) key-val) res)))
db qry run-id)))
keys)
(reverse res)))
(define (keys->keystr keys) ;; => key1,key2,key3,additiona1, ...
(string-intersperse (map key:get-fieldname keys) ","))
(define (args:usage . a) #f)
;; keys->vallist is called several times (quite unnecessarily), use this hash to suppress multiple
;; reporting of missing keys on the command line.
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
(let ((keys '())) ;; keys are vectors <fieldname,type>
(sqlite3:for-each-row (lambda (fieldname fieldtype)
(set! keys (cons (vector fieldname fieldtype) keys)))
db
"SELECT fieldname,fieldtype FROM keys ORDER BY id ASC;")
(reverse keys))) ;; could just sort desc?
(define (keys->keystr keys) ;; => key1,key2,key3,additiona1, ...
(string-intersperse (map key:get-fieldname keys) ","))
(define (args:usage . a) #f)
;; keys->vallist is called several times (quite unnecessarily), use this hash to suppress multiple
;; reporting of missing keys on the command line.
|