(declare (block) (standard-bindings) (extended-bindings))
(begin
  (define std/db/dbi#connection::t
    (make-struct-type
     'std/db/dbi#connection::t
     '#f
     '4
     'connection
     '()
     ':init!
     '(e txn-begin txn-commit txn-abort)))
  (define std/db/dbi#connection?
    (make-struct-predicate std/db/dbi#connection::t))
  (define std/db/dbi#make-connection
    (lambda _$args209102_
      (apply make-struct-instance std/db/dbi#connection::t _$args209102_)))
  (define std/db/dbi#connection-e
    (make-struct-field-accessor std/db/dbi#connection::t '0))
  (define std/db/dbi#connection-txn-begin
    (make-struct-field-accessor std/db/dbi#connection::t '1))
  (define std/db/dbi#connection-txn-commit
    (make-struct-field-accessor std/db/dbi#connection::t '2))
  (define std/db/dbi#connection-txn-abort
    (make-struct-field-accessor std/db/dbi#connection::t '3))
  (define std/db/dbi#connection-e-set!
    (make-struct-field-mutator std/db/dbi#connection::t '0))
  (define std/db/dbi#connection-txn-begin-set!
    (make-struct-field-mutator std/db/dbi#connection::t '1))
  (define std/db/dbi#connection-txn-commit-set!
    (make-struct-field-mutator std/db/dbi#connection::t '2))
  (define std/db/dbi#connection-txn-abort-set!
    (make-struct-field-mutator std/db/dbi#connection::t '3))
  (define std/db/dbi#statement::t
    (make-struct-type 'std/db/dbi#statement::t '#f '1 'statement '() '#f '(e)))
  (define std/db/dbi#statement?
    (make-struct-predicate std/db/dbi#statement::t))
  (define std/db/dbi#make-statement
    (lambda _$args209099_
      (apply make-struct-instance std/db/dbi#statement::t _$args209099_)))
  (define std/db/dbi#statement-e
    (make-struct-field-accessor std/db/dbi#statement::t '0))
  (define std/db/dbi#statement-e-set!
    (make-struct-field-mutator std/db/dbi#statement::t '0))
  (define std/db/dbi#connection:::init!
    (lambda (_self209096_ _e209097_)
      (if (##fx< '1 (##vector-length _self209096_))
          (##vector-set! _self209096_ '1 _e209097_)
          (error '"struct-instance-init!: too many arguments for struct"
                 _self209096_))))
  (bind-method!
   std/db/dbi#connection::t
   ':init!
   std/db/dbi#connection:::init!
   '#f)
  (define std/db/dbi#sql-error::t
    (make-struct-type
     'std/db/dbi#sql-error::t
     error::t
     '0
     'sql-error
     '()
     '#f
     '()))
  (define std/db/dbi#sql-error?
    (make-struct-predicate std/db/dbi#sql-error::t))
  (define std/db/dbi#make-sql-error
    (lambda _$args208971_
      (apply make-struct-instance std/db/dbi#sql-error::t _$args208971_)))
  (define std/db/dbi#raise-sql-error
    (lambda (_where208967_ _what208968_ . _irritants208969_)
      (raise (make-struct-instance
              std/db/dbi#sql-error::t
              _what208968_
              _irritants208969_
              _where208967_))))
  (define std/db/dbi#sql-connect
    (lambda (_connect208962_ . _args208963_)
      (let ((_conn208965_ (apply _connect208962_ _args208963_)))
        (make-will _conn208965_ std/db/dbi#sql-close)
        _conn208965_)))
  (define std/db/dbi#sql-close
    (lambda (_conn208912_)
      (let* ((_conn208913208922_ _conn208912_)
             (_E208915208926_
              (lambda () (error '"No clause matching" _conn208913208922_)))
             (_K208916208939_
              (lambda (_txn-abort208929_
                       _txn-commit208930_
                       _txn-begin208931_
                       _e208932_)
                (if _e208932_
                    (with-unwind-protect
                     (lambda ()
                       (if _txn-begin208931_
                           (with-exception-catcher
                            void
                            (lambda ()
                              (call-method _txn-begin208931_ 'finalize)))
                           '#!void)
                       (if _txn-commit208930_
                           (with-exception-catcher
                            void
                            (lambda ()
                              (call-method _txn-commit208930_ 'finalize)))
                           '#!void)
                       (if _txn-abort208929_
                           (with-exception-catcher
                            void
                            (lambda ()
                              (call-method _txn-abort208929_ 'finalize)))
                           '#!void)
                       (call-method _conn208912_ 'close))
                     (lambda ()
                       (##structure-set!
                        _conn208912_
                        '#f
                        '1
                        std/db/dbi#connection::t
                        '#f)
                       (##structure-set!
                        _conn208912_
                        '#f
                        '2
                        std/db/dbi#connection::t
                        '#f)
                       (##structure-set!
                        _conn208912_
                        '#f
                        '3
                        std/db/dbi#connection::t
                        '#f)
                       (##structure-set!
                        _conn208912_
                        '#f
                        '4
                        std/db/dbi#connection::t
                        '#f)))
                    '#!void))))
        (if (##structure-instance-of?
             _conn208913208922_
             'std/db/dbi#connection::t)
            (let* ((_e208917208942_ (##vector-ref _conn208913208922_ '1))
                   (_e208945_ _e208917208942_)
                   (_e208918208947_ (##vector-ref _conn208913208922_ '2))
                   (_txn-begin208950_ _e208918208947_)
                   (_e208919208952_ (##vector-ref _conn208913208922_ '3))
                   (_txn-commit208955_ _e208919208952_)
                   (_e208920208957_ (##vector-ref _conn208913208922_ '4))
                   (_txn-abort208960_ _e208920208957_))
              (_K208916208939_
               _txn-abort208960_
               _txn-commit208955_
               _txn-begin208950_
               _e208945_))
            (_E208915208926_)))))
  (define std/db/dbi#connection::destroy std/db/dbi#sql-close)
  (bind-method!
   std/db/dbi#connection::t
   'destroy
   std/db/dbi#connection::destroy
   '#f)
  (define std/db/dbi#sql-txn-do
    (lambda (_conn208758_ _sql208759_ _getf208760_ _setf208761_)
      (let* ((_conn208762208768_ _conn208758_)
             (_E208764208772_
              (lambda () (error '"No clause matching" _conn208762208768_)))
             (_K208765208782_
              (lambda (_e208775_)
                (if (not _e208775_)
                    (error '"Invalid operation; connection closed"
                           _conn208758_)
                    (let ((_$e208777_ (_getf208760_ _conn208758_)))
                      (if _$e208777_
                          (std/db/dbi#sql-exec _$e208777_)
                          (let ((_stmt208780_
                                 (call-method
                                  _conn208758_
                                  'prepare
                                  _sql208759_)))
                            (_setf208761_ _conn208758_ _stmt208780_)
                            (std/db/dbi#sql-exec _stmt208780_))))))))
        (if (##structure-instance-of?
             _conn208762208768_
             'std/db/dbi#connection::t)
            (let* ((_e208766208785_ (##vector-ref _conn208762208768_ '1))
                   (_e208788_ _e208766208785_))
              (_K208765208782_ _e208788_))
            (_E208764208772_)))))
  (define std/db/dbi#sql-txn-begin
    (lambda (_conn208756_)
      (std/db/dbi#sql-txn-do
       _conn208756_
       '"BEGIN TRANSACTION"
       std/db/dbi#connection-txn-begin
       std/db/dbi#connection-txn-begin-set!)))
  (define std/db/dbi#sql-txn-commit
    (lambda (_conn208754_)
      (std/db/dbi#sql-txn-do
       _conn208754_
       '"COMMIT"
       std/db/dbi#connection-txn-commit
       std/db/dbi#connection-txn-commit-set!)))
  (define std/db/dbi#sql-txn-abort
    (lambda (_conn208752_)
      (std/db/dbi#sql-txn-do
       _conn208752_
       '"ROLLBACK"
       std/db/dbi#connection-txn-abort
       std/db/dbi#connection-txn-abort-set!)))
  (define std/db/dbi#sql-prepare
    (lambda (_conn208747_ _text208748_)
      (if (##structure-ref _conn208747_ '1 std/db/dbi#connection::t '#f)
          (let ((_stmt208750_
                 (call-method _conn208747_ 'prepare _text208748_)))
            (make-will _stmt208750_ std/db/dbi#sql-finalize)
            _stmt208750_)
          (error '"Invalid operation; connection closed" _conn208747_))))
  (define std/db/dbi#sql-finalize
    (lambda (_stmt208743_)
      (if (##structure-ref _stmt208743_ '1 std/db/dbi#statement::t '#f)
          (with-unwind-protect
           (lambda () (call-method _stmt208743_ 'finalize))
           (lambda ()
             (##structure-set!
              _stmt208743_
              '#f
              '1
              std/db/dbi#statement::t
              '#f)))
          '#!void)))
  (define std/db/dbi#statement::destroy std/db/dbi#sql-finalize)
  (bind-method!
   std/db/dbi#statement::t
   'destroy
   std/db/dbi#statement::destroy
   '#f)
  (define std/db/dbi#sql-bind
    (lambda (_stmt208618_ . _args208619_)
      (if (##structure-ref _stmt208618_ '1 std/db/dbi#statement::t '#f)
          (apply call-method _stmt208618_ 'bind _args208619_)
          (error '"Invalid operation; statement finalized" _stmt208618_))))
  (define std/db/dbi#sql-clear
    (lambda (_stmt208616_)
      (if (##structure-ref _stmt208616_ '1 std/db/dbi#statement::t '#f)
          (call-method _stmt208616_ 'clear)
          (error '"Invalid operation; statement finalized" _stmt208616_))))
  (define std/db/dbi#sql-reset
    (lambda (_stmt208614_)
      (if (##structure-ref _stmt208614_ '1 std/db/dbi#statement::t '#f)
          (call-method _stmt208614_ 'reset)
          (error '"Invalid operation; statement finalized" _stmt208614_))))
  (define std/db/dbi#sql-reset/clear
    (lambda (_stmt208612_)
      (if (##structure-ref _stmt208612_ '1 std/db/dbi#statement::t '#f)
          (begin
            (call-method _stmt208612_ 'reset)
            (call-method _stmt208612_ 'clear))
          (error '"Invalid operation; statement finalized" _stmt208612_))))
  (define std/db/dbi#sql-eval-e
    (lambda (_eval-e208603_ _conn208604_ _sql208605_ _args208606_)
      (let ((_stmt208608_ (std/db/dbi#sql-prepare _conn208604_ _sql208605_)))
        (with-unwind-protect
         (lambda ()
           (if (null? _args208606_)
               '#!void
               (apply std/db/dbi#sql-bind _stmt208608_ _args208606_))
           (_eval-e208603_ _stmt208608_))
         (lambda () (std/db/dbi#sql-finalize _stmt208608_))))))
  (define std/db/dbi#sql-eval
    (lambda (_conn208599_ _sql208600_ . _args208601_)
      (std/db/dbi#sql-eval-e
       std/db/dbi#sql-exec
       _conn208599_
       _sql208600_
       _args208601_)))
  (define std/db/dbi#sql-eval-query
    (lambda (_conn208595_ _sql208596_ . _args208597_)
      (std/db/dbi#sql-eval-e
       std/db/dbi#sql-query
       _conn208595_
       _sql208596_
       _args208597_)))
  (define std/db/dbi#sql-exec
    (lambda (_stmt208593_)
      (if (##structure-ref _stmt208593_ '1 std/db/dbi#statement::t '#f)
          (begin
            (call-method _stmt208593_ 'exec)
            (call-method _stmt208593_ 'reset)
            '#!void)
          (error '"Invalid operation; statement finalized" _stmt208593_))))
  (define std/db/dbi#sql-query
    (lambda (_stmt208551_)
      (let ((_iterable208574_ (std/db/dbi#in-sql-query _stmt208551_))
            (_iter-do208576_
             (lambda (_val208553_)
               (let* ((_val208555208560_ _val208553_)
                      (_E208557208564_
                       (lambda ()
                         (error '"No clause matching" _val208555208560_)))
                      (_K208558208569_ (lambda (_row208567_) _row208567_))
                      (_row208572_ _val208555208560_))
                 (_K208558208569_ _row208572_)))))
        (if (pair? _iterable208574_)
            (map _iter-do208576_ _iterable208574_)
            (if (null? _iterable208574_)
                '()
                (let ((_it208579_ (std/iter#iter _iterable208574_)))
                  (let _lp208582_ ((_rval208585_ '()))
                    (let ((_val208588_ (std/iter#iter-next! _it208579_)))
                      (if (eq? std/iter#iter-end _val208588_)
                          (begin
                            (std/iter#iter-fini! _it208579_)
                            (reverse _rval208585_))
                          (let ((_xval208590_ (_iter-do208576_ _val208588_)))
                            (_lp208582_
                             (cons _xval208590_ _rval208585_))))))))))))
  (define std/db/dbi#:iter::statement
    (lambda (_stmt208549_) (std/db/dbi#in-sql-query _stmt208549_)))
  (std/generic/dispatch#generic-bind!
   std/iter#:iter::t
   (cons (std/generic/dispatch#type-linearize-class std/db/dbi#statement::t)
         '())
   std/db/dbi#:iter::statement)
  (define std/db/dbi#in-sql-query
    (lambda (_stmt208426_)
      (letrec ((_next208428_
                (lambda (_it208457_)
                  (let* ((_it208458208464_ _it208457_)
                         (_E208460208468_
                          (lambda ()
                            (error '"No clause matching" _it208458208464_)))
                         (_K208461208475_
                          (lambda (_stmt208471_)
                            (let ((_r208473_
                                   (call-method _stmt208471_ 'query-fetch)))
                              (if (std/iter#iter-end? _r208473_)
                                  std/iter#iter-end
                                  (call-method _stmt208471_ 'query-row))))))
                    (if (##structure-direct-instance-of?
                         _it208458208464_
                         'std/iter#iterator::t)
                        (let* ((_e208462208478_
                                (##vector-ref _it208458208464_ '1))
                               (_stmt208481_ _e208462208478_))
                          (_K208461208475_ _stmt208481_))
                        (_E208460208468_)))))
               (_fini208429_
                (lambda (_it208433_)
                  (let* ((_it208434208440_ _it208433_)
                         (_E208436208444_
                          (lambda ()
                            (error '"No clause matching" _it208434208440_)))
                         (_K208437208449_
                          (lambda (_stmt208447_)
                            (if _stmt208447_
                                (begin
                                  (call-method _stmt208447_ 'query-fini)
                                  (##direct-structure-set!
                                   _it208433_
                                   '#f
                                   '1
                                   std/iter#iterator::t
                                   '#f))
                                '#!void))))
                    (if (##structure-direct-instance-of?
                         _it208434208440_
                         'std/iter#iterator::t)
                        (let* ((_e208438208452_
                                (##vector-ref _it208434208440_ '1))
                               (_stmt208455_ _e208438208452_))
                          (_K208437208449_ _stmt208455_))
                        (_E208436208444_))))))
        (if (##structure-ref _stmt208426_ '1 std/db/dbi#statement::t '#f)
            (let ((_it208431_
                   (let ((__obj209104 (make-object std/iter#iterator::t '3)))
                     (if (##fx< '3 (##vector-length __obj209104))
                         (begin
                           (##vector-set! __obj209104 '1 _stmt208426_)
                           (##vector-set! __obj209104 '2 _next208428_)
                           (##vector-set! __obj209104 '3 _fini208429_))
                         (error '"struct-instance-init!: too many arguments for struct"
                                __obj209104))
                     __obj209104)))
              (make-will _it208431_ _fini208429_)
              (call-method _stmt208426_ 'query-start)
              _it208431_)
            (error '"Invalid operation; statement finalized" _stmt208426_)))))
  (define std/db/dbi#sql-columns
    (lambda (_stmt208424_)
      (if (##structure-ref _stmt208424_ '1 std/db/dbi#statement::t '#f)
          (call-method _stmt208424_ 'columns)
          (error '"Invalid operation; statement finalized" _stmt208424_)))))
