- $db q #!key (default '()) valuesprocedure
Execute the given query (q) on the database and return the result as a list of lists or default if the result set is empty.
The values keyword parameter (a list) is a list of values to replace the placeholders in the query.
($db "insert into foo (bar, baz) values (?, ?)" values: '("bar-val" "baz-val"))
Note that $db is supposed to be used in the context of request handlers (i.e., in the body of a lambda bound to a uri path by define-page).
If you want to use $db out of the context of request handlers, you'll have to manage database connections yourself. Basically, you have to parameterize db-connection with the actual connection object. Example:
(parameterize ((db-connection (open-database (db-credentials)))) ($db the-query) (close-database (db-connection)))