-
Notifications
You must be signed in to change notification settings - Fork 0
Home
see also: https://gitlab.com/ffox8/artanis/wikis/home
Here some real world usage examples which do work via copy & paste:
` ;; a small example to demonstrate display of database items on the webpage. Requires the database to be up and running already. ;; when settings such as mysql vs. postgresql or engine-guile vs. engine-raganok are changed, expect errors from guile. ;; see: https://www.gnu.org/software/artanis/manual/manual.html#org7e1f4ef ;; https://gitlab.com/ffox8/artanis/wikis/home/ ;; https://github.com/ffox8/artanis/wiki
(use-modules (artanis artanis)) (init-server) ;;use-module = BIG FAT ERROR ---> unbound var
(define conn (connect-db 'mysql #:db-username "root" #:db-name "mmr_blog" #:db-passwd "123")) (define mtable (map-table-from-DB conn))
((mtable 'create 'Persons3 '((name varchar 10) (age integer) (email varchar 20))) 'valid?) ;; ==> #t (mtable 'set 'Persons3 #:name "nala" #:age 99 #:email "[email protected]") (mtable 'get 'Persons3 #:columns '(name email)) ;; ==> ((("name" . "nala") ("email" . "[email protected]")))
;; db=mmr_blog root 123 works OK
;; surf to http://127.0.0.1:3000/dbtest
(get "/dbtest" #:conn #t ; apply for a DB connection from pool (lambda (rc) (let ((mtable (map-table-from-DB (:conn rc)))) (object->string (mtable 'get 'Persons3 #:columns '(name email))))))
(run #:use-db? #t #:dbd 'mysql #:db-username "root" #:db-name "mmr_blog" #:db-passwd "123" #:port 3000)
`