2023-04-05

(sph sql)

create sql-statements from scheme data

part of sph-lib

module name

(sph sql)

exported bindings

variable: sph-sql-description
procedure: sql-columns columns ->
pair/list/string/boolean -> string
construct the \"column\" part of an sql expression
procedure: sql-columns-list columns ->
(pair/list/string ...) -> list
procedure: sql-create-index name table-name columns [replace] ->
string string string ... -> string
procedure: sql-create-table table-name columns [replace add] ->
string ((name type options ...)/string ...) [boolean string:custom-suffix]
procedure: sql-delete table-name [where options] ->
string sql-where sql-options -> string
procedure: sql-delete-table table-name ->
string -> string
procedure: sql-insert table-name data [options] ->
string string/boolean/((column-name . data) ...) -> string
procedure: sql-insert-values a ->
alist -> string
convert to a sql values specification for the insert statement
((a . 1) (b . 2)) -> (a,b)values(1,2)
procedure: sql-select tables [columns where options] ->
string/(string ...) [string/(string ...)/boolean:all-columns string/list/pair string/list] -> string
procedure: sql-string a ->
string -> string
escapes string values for sql
procedure: sql-update table-name set [where options] ->
string pair/list/string sql-where list -> string
example: (sql-update \"table-name\" ((a . 1) (b . 2))) -> \"update table-name set a=1 and b=2\"
procedure: sql-value a ->
any -> string
convert types, escape and quote strings
procedure: sql-where conditions ->
string/pair/list -> string
procedure: sql-where-condition expr ->
for creating a \"where\" part sql separately.
\"not\" in row-expressions will always be in front of the column-condition in the resulting query. sqlite for example does not understand
\"not c=NULL\" as one might expect. use \"ISNULL\" instead of \"NULL\" in this case.