.
This commit is contained in:
@@ -148,9 +148,9 @@ Below is an example SQLite backend implementation that stores fields in a table:
|
|||||||
(require db)
|
(require db)
|
||||||
(require racket/vector)
|
(require racket/vector)
|
||||||
|
|
||||||
@;{;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;}
|
@; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
@;{;; Conversion of field values}
|
@; ;; Conversion of field values
|
||||||
@;{;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;}
|
@; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(define (value->string s-expr)
|
(define (value->string s-expr)
|
||||||
(let ((o (open-output-string)))
|
(let ((o (open-output-string)))
|
||||||
@@ -161,9 +161,9 @@ Below is an example SQLite backend implementation that stores fields in a table:
|
|||||||
(let ((o (open-input-string str)))
|
(let ((o (open-input-string str)))
|
||||||
(read o)))
|
(read o)))
|
||||||
|
|
||||||
@;{;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;}
|
@; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
@;{;; Database storage backend}
|
@; ;; Database storage backend
|
||||||
@;{;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;}
|
@; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(define conn (sqlite3-connect #:database "roos.db" #:mode 'create))
|
(define conn (sqlite3-connect #:database "roos.db" #:mode 'create))
|
||||||
(query-exec conn "CREATE TABLE IF NOT EXISTS store (class TEXT, id TEXT, field TEXT, val TEXT)")
|
(query-exec conn "CREATE TABLE IF NOT EXISTS store (class TEXT, id TEXT, field TEXT, val TEXT)")
|
||||||
@@ -254,7 +254,7 @@ This example builds an address book with persistent reference to persons, using
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@;{;; Create sample data}
|
@; ;; Create sample data
|
||||||
(define b (-! book))
|
(define b (-! book))
|
||||||
|
|
||||||
(define (adder n t)
|
(define (adder n t)
|
||||||
@@ -270,7 +270,7 @@ This example builds an address book with persistent reference to persons, using
|
|||||||
|
|
||||||
(-> b (for-each (lambda (p) (displayln (-> p name)))))
|
(-> b (for-each (lambda (p) (displayln (-> p name)))))
|
||||||
|
|
||||||
@{;; Reopen addressbook later from persistent storage}
|
@; ;; Reopen addressbook later from persistent storage
|
||||||
(define a (-! book))
|
(define a (-! book))
|
||||||
(-> b (for-each (lambda (p) (displayln (-> p name)))))
|
(-> b (for-each (lambda (p) (displayln (-> p name)))))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user