[gambit-list] Introduction, MySQL FFI
Jonathan Arkell
jonnay at jonnay.net
Sat Aug 12 12:46:14 EDT 2006
Hi List
I've been playing around with Gambit for the past little while, and I
really like it. Congrats and thanks to Marc Feeley (and others) for all
their hard work.
I have just finished putting together an alpha-quality MySQL FFI for
gambit, available here:
http://blog.jonnay.net/archives/742-A-Gambit-MySQL-Gambit-FFI.html
Direct Link to source:
http://blog.jonnay.net/plugin/dlfile_4
It still needs plenty of work (a proper test suite, better handling of
field data, documentation, implementing mysql_real_escape_string,
implementing the rest of the MySQL c API) but it should be enough to get
you connected to a myself database, and run some queries.
I've also built some simple wrappers and plan to build more, taking into
account the work that Oleg Kiselyov has done in this area
(http://okmij.org/ftp/Scheme/index.html#databases) Any comments,
suggestions, bug fixes or enhancements are welcome.
Here is a simple example of how to use the FFI
(define test-server (make-mysql-server "127.0.0.1"
"test"
"test"
"test"
0
""
0))
(define test-mysql-result->list
(lambda ()
(print-line "testing mysql-result->list")
(with-mysql-connection test-server
(lambda (mysql-handle)
(mysql-query-with-result mysql-handle "select * from test"
(lambda (result)
(print-line "Number of rows: " (mysql-num-rows result))
(pp (mysql-result->list result))
(pp (mysql-result->list result))
(pp (mysql-result->list result))))))))
Cheers!
--
,-------. The Cute Grim Floating Skull of Hello Cthulu Says
/ | | \
/ _ ^ _ \ Listen To Crazy Shaman Techno
\_/ }|||{ \_/ http://www.jonnay.net
'^"^` I'm Jonnay!
More information about the Gambit-list
mailing list