- get-one-row db query #!rest paramsprocedure
Execute the query on the database connection db and return the first row in the set. The params should be rest arguments which replace the corresponding "?" placeholders in query.
The returned row is represented by a vector with the row's fields or #f if the query returns an empty set.
NOTE: This will still retrieve the entire result set, despite only returning the one row. So it's still up to you to add LIMIT 1 or FETCH FIRST ROW ONLY to your query!
Example:
(define mydb (open 'sqlite3 '((dbname . "/tmp/db")))) (let ((tuple (get-one-row mydb "SELECT name, year FROM films WHERE name = ?" "The Godfather"))) (print (vector-ref tuple 0) " -- " (vector-ref tuple 1))) ;; This will print something like: ;; The Godfather -- 1972