@@ -69,10 +69,18 @@ by backticks and separated by commas. @examples[#:eval my-eval (list->sql-fields '("id" "name" "address")) (list->sql-fields '(or use symbols))] + +@defproc[(list->sql-values [lst (listof any/c)]) string?] + +Given a list of values, return a string containing those values separated by commas inside a pair of +parentheses. Any string values in the list will be surrounded by quote marks. + +@examples[#:eval my-eval +(list->sql-values '(0 "hello" NULL 34))] @defproc[(list->sql-parameters [lst (listof stringish?)]) string?] Given a list of values, return a single string with numbered parameter placeholders, suitable for use in a parameterized SQL query. @@ -144,10 +152,18 @@ (make-insert/replace-query 'vals '(a b c))] This query relies on the fact that in SQLite every table contains a @tt{rowid} column by default. For more information on why/how the query works, see @ext-link["https://sqlite.org/lang_insert.html"]{the SQLite docs for @tt{INSERT}}. + +@defproc[(make-insert-rows-query [table stringish?] [fields (listof stringish?)] [rows (listof +(listof any/c))]) string?] + +Returns a SQLite query string for inserting multiple rows. + +@examples[#:eval my-eval +(make-insert-rows-query 'people '(id name) '((1 "Alice") (2 "Bob")))] @defproc[(make-select-query [table stringish?] [fields (listof stringish?)] [#:where where-clause stringish?]) string?] Returns a SQLite query string for selecting rows from the database.