sqlite3 egg example added by wasamasa on Thu Nov 19 21:16:22 2020

;; adapted from sqlite3 tests
(define db-timeout 3000)
(define (call-with-database path proc #!optional finalize-statements?)
  (let ((db #f))
    (dynamic-wind
        (lambda ()
          (set! db (open-database path))
          (set-busy-handler! db (make-busy-timeout db-timeout)))
        (lambda ()
          (proc db))
        (lambda ()
          (and-let* ((d db))
            (set! db #f)
            (finalize! d finalize-statements?))))))

(call-with-database db-path
  (lambda (db)
    (execute db sql-statement sql-arg sql-arg2 sql-arg3)))