44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
(db (sqlite3:open-database dbpath)) ;; (never-give-up-open-db dbpath))
(handler (make-busy-timeout 36000)))
(sqlite3:set-busy-handler! db handler)
(if (not dbexists)
(db:initialize db))
(cond
((and (not tdataexists)(not dbexists))
(db:initialize-tdat))
((not tdataexists)
(db:migrate-to-testdata db)))
(db:attach-testdata db)
db))
(define (db:initialize db)
(let* ((configdat (car *configinfo*)) ;; tut tut, global warning...
(keys (config-get-fields configdat))
(havekeys (> (length keys) 0))
(keystr (keys->keystr keys))
(fieldstr (keys->key/field keys)))
(for-each (lambda (key)
|
|
>
>
>
>
>
>
>
>
>
>
>
>
|
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
72
73
74
75
|
(db (sqlite3:open-database dbpath)) ;; (never-give-up-open-db dbpath))
(handler (make-busy-timeout 36000)))
(sqlite3:set-busy-handler! db handler)
(if (not dbexists)
(db:initialize db))
(cond
((and (not tdataexists)(not dbexists))
(db:initialize-test-data-db))
((not tdataexists)
(db:migrate-to-testdata db)))
(db:attach-testdata db)
db))
;; Initialize the testdata db
(define (db:initialize-test-data-db)
(let ((tdb (sqlite3:open-database (conc *toppath* "/testdata.db"))))
(sqlite3:execute tdb "CREATE TABLE test_info (
id INTEGER PRIMARY KEY,
diskspace INTEGER,
cpuusage INTEGER,
tmpdiskspace INTEGER,
memoryusage INTEGER);")
(sqlite3:finalize! tdb)))
;; Initialize the main db
(define (db:initialize db)
(let* ((configdat (car *configinfo*)) ;; tut tut, global warning...
(keys (config-get-fields configdat))
(havekeys (> (length keys) 0))
(keystr (keys->keystr keys))
(fieldstr (keys->key/field keys)))
(for-each (lambda (key)
|