hello,

> ...
>        (stmt (sqlite-prepare db "INSERT INTO foos(name) VALUES(?);")))

i'd rather bind the statment in scheme _anyway_ if i was you.

david

;; --

(use-modules (sqlite3))

(define db (sqlite-open "ex0.db"))

(define (sqlite/command db command)
  (let ((stmt (sqlite-prepare db command)))
    (sqlite-step stmt)
    (sqlite-finalize stmt)
    (if #f #f)))

(define (my-insert new-name)
  (sqlite/command db (format #f "INSERT INTO foos(name) VALUES('~A')" 
new-name)))

(sqlite/command db "DROP TABLE IF EXISTS foos;")
(sqlite/command db "CREATE TABLE foos(dbid INTEGER PRIMARY KEY, name TEXT);")

(for-each (lambda (name)
            (my-insert name))
    '("foo-1" "foo-2" "foo-3"))


Reply via email to