412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
|
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
|
-
+
|
;; just tests, test_steps and test_data tables
(define db:sync-tests-only
(list
;; (list "strs"
;; '("id" #f)
;; '("str" #f))
(list "tests"
'("id" "INTEGER")
'("id" "INTEGER" 'key)
'("run_id" "INTEGER")
'("testname" "TEXT")
'("host" "TEXT")
'("cpuload" "REAL")
'("diskfree" "INTEGER")
'("uname" "TEXT")
'("rundir" "TEXT")
|
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
|
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
-
+
-
+
-
+
-
+
+
+
+
-
+
-
+
|
'("run_duration" "INTEGER")
'("comment" "TEXT")
'("event_time" "INTEGER")
'("fail_count" "INTEGER")
'("pass_count" "INTEGER")
'("archived" "INTEGER"))
(list "test_steps"
'("id" "INTEGER")
'("id" "INTEGER" 'key)
'("test_id" "INTEGER")
'("stepname" "TEXT")
'("state" "TEXT")
'("status" "TEXT")
'("event_time" "INTEGER")
'("comment" "TEXT")
'("logfile" "TEXT"))
(list "test_data"
'("id" "INTEGER")
'("id" "INTEGER" 'key)
'("test_id" "INTEGER")
'("category" "TEXT")
'("variable" "TEXT")
'("value" "REAL")
'("expected" "REAL")
'("tol" "REAL")
'("units" "TEXT")
'("comment" "TEXT")
'("status" "TEXT")
'("type" "TEXT"))))
;; needs db to get keys, this is for syncing all tables
;;
(define (db:sync-main-list dbstruct)
(let ((keys (db:get-keys dbstruct)))
(list
(list "keys"
'("id" "INTEGER")
'("id" "INTEGER" 'key)
'("fieldname" "TEXT")
'("fieldtype" "TEXT"))
(list "metadat" '("var" "TEXT") '("val" "TEXT"))
(list "metadat"
'("id" "INTEGER" 'key)
'("var" "TEXT")
'("val" "TEXT"))
(list "runs"
'("id" "INTEGER")
'("id" "INTEGER" 'key)
'("release" "TEXT")
'("iteration" "TEXT")
'("testsuite_mode" "TEXT")
'("runname" "TEXT")
'("state" "TEXT")
'("status" "TEXT")
'("owner" "TEXT")
'("event_time" "INTEGER")
'("comment" "TEXT")
'("fail_count" "INTEGER")
'("pass_count" "INTEGER"))
(list "test_meta"
'("id" "INTEGER")
'("id" "INTEGER" 'key)
'("testname" "TEXT")
'("owner" "TEXT")
'("description" "TEXT")
'("reviewed" "INTEGER")
'("iterated" "TEXT")
'("avg_runtime" "REAL")
'("avg_disk" "REAL")
|
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
|
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
|
-
+
|
(let* ((prep ""))
(set! prep (string-intersperse (map cadr fields) ","))
(set! prep (conc "PREPARE fullins (" prep ") AS INSERT INTO " tablename " ( " (string-intersperse (map car fields) ",") " ) VALUES ( ")) ;;maybe add lookup in the future depending on where types are needed
(let loop ((i 1))
(set! prep (conc prep "$" i ","))
(if (< i (- num-fields 1))
(loop (+ i 1))
(set! prep (conc prep "$" (+ i 1) " ) ON CONFLICT DO NOTHING;"))))
(set! prep (conc prep "$" (+ i 1) " );"))))
(set! full-ins prep)))
(let* ((db (dbi:convert (db:dbdat-get-db targdb)))
(stmth (dbi:prepare db full-ins)))
;; (db:delay-if-busy targdb) ;; NO WAITING
(for-each
(lambda (fromdat-lst)
(dbi:with-transaction
|