Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close
; A minimal MySQL client library for chicken-scheme.
;
; Requires MySQL database system development components,
; libmysqlclient and mysql_config. The mysql_config
; program needs to be in the $PATH.
;
; To install, from the directory containing mysql-client.setup:
;
;   chicken-install -s -test
;
; To uninstall:
;
;   chicken-uninstall -s mysql-client
;
; Example program below, to compile and run:
;
;   make
;   ./scm-mysql-example
;
; 
; To escape parameters used in a query, a placeholder
; syntax can be used, and an association list provided.
;
; Example:

;   (sql "SELECT * FROM t1 WHERE c1 = $1 AND c2 = $2" '(($1 . "value1") ($2 . "value2")))
;
; For access to the underlying MYSQL connection pointer object,
; pass a procedure rather than a string. The provided procedure will 
; be called with the connection pointer as the first argument.
; 
; Example:
;
;   (sql (lambda(c) (printf "Connection pointer: ~S~%" c)))
;

(use mysql-client)

(define sql (make-mysql-connection "localhost" "root" #f "information_schema"))

(define fetch (sql "select * from schemata"))

(define (fetch-loop)
  (let ((row (fetch)))
    (if row 
       (begin
          (printf "~A~%" row)
          (fetch-loop)))))

(fetch-loop)


Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.