This is an egg for CHICKEN 3, the unsupported old release. You're almost certainly looking for the CHICKEN 4 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
A library for using the SQLite database engine.
This extension is obsolete. Consider using sqlite3 instead.
Original code by Lars Rustemeier, with modifications by felix winkelmann.
This extension provides an interface for the SQLite relational database. Any errors triggered by the database system signal a composite condition of the exn and sqlite kinds.[procedure] (sqlite:open FILENAME [BOOL])
Opens the database FILENAME and returns a foreign pointer object representing the database in memory. If the file does not exist and the optional flag BOOL is false, a new database is created, otherwise an error is signaled.[procedure] (sqlite:close DB)
Closes the database represented by DB.[procedure] (sqlite:execute DB QUERY)
Executes the SQL command in the string QUERY for the database DB and returns a list of all returned rows, where each row is a vector containing strings (one for each column).[procedure] (sqlite:iterator DB QUERY)
Returns an iterator object from the database DB and the SQL command passed in the string QUERY.[procedure] (sqlite:next ITERATOR)
Returns a vector containing the columns of the next result row from the query represented by ITERATOR. If no more rows are available, #f is returned.[procedure] (sqlite:finish ITERATOR)
Frees up resources allocated by ITERATOR.[procedure] (sqlite:call-with-query DB QUERY PROC)
Calls the procedure PROC for each result-row returned by the SQL command QUERY with a vector containing the columns.[procedure] (sqlite:iterator? X)
Returns #t if X is an iterator object or #f otherwise.
Create a table of number pairs:
(use sqlite) (define db (sqlite:open "foo.db")) (sqlite:execute db "CREATE TABLE t1(a int, b int);") (for-each (lambda (i) (sqlite:execute db (sprintf "INSERT INTO t1 VALUES(~A, ~A);" i (* i i)) ) ) (iota 10) ) (sqlite:execute db "SELECT * FROM t1;") ; returns ; (#("0" "0") #("1" "1") #("2" "4") #("3" "9") #("4" "16") #("5" "25") #("6" "36") #("7" "49") #("8" "64") #("9" "81")) (sqlite:call-with-query db "SELECT * FROM t1;" (compose print car vector->list)) ; prints: ; 0 ; 1 ; 4 ; 9 ; 16 ; 25 ; 36 ; 49 ; 64 ; 81 (sqlite:close db) ; cleaning up is always good.
- 1.2 Adapted to new setup scheme.
- 1.1 Fixed missing sqlite:finish in sqlite:execute [Thanks to Lars Rustemeier]
- 1.0 Initial release
Copyright (c) 2000-2003, Lars Rustemeier and Felix L. Winkelmann All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICESLOSS OF USE, DATA, OR PROFITSOR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.