sqlite/row
col-count
(col-count [stmt :int] :int)
return the number of result columns in a prepared statement.
| stmt | statement handle |
Column count as :int.
(col-count stmt) ; => 3
Since: P2
col-name
(col-name [stmt :int i :int] :cstr)
return the name of a result column at 0-based index i.
| stmt | statement handle (stepped to SQLITE_ROW) | |
| i | 0-based column index |
Column name as :cstr (valid until stmt is finalized).
(col-name stmt 0) ; => "id"
Since: P2
col-int
(col-int [stmt :int i :int] :int)
return the integer value of result column i from a stepped statement.
| stmt | statement handle at SQLITE_ROW | |
| i | 0-based column index |
Column value as :int (int64_t).
(col-int stmt 0) ; => 42
Since: P2
col-real
(col-real [stmt :int i :int] :float)
return the real value of result column i from a stepped statement.
| stmt | statement handle at SQLITE_ROW | |
| i | 0-based column index |
Column value as :float (double).
(col-real stmt 1) ; => 3.14
Since: P2
col-text
(col-text [stmt :int i :int] :cstr)
return the text value of result column i from a stepped statement.
| stmt | statement handle at SQLITE_ROW | |
| i | 0-based column index |
Column text as :cstr; empty string if SQL NULL; valid until next step or finalize.
(col-text stmt 1) ; => "Alice"
Since: P2
col-type
(col-type [stmt :int i :int] :int)
return the storage type code of result column i.
| stmt | statement handle at SQLITE_ROW | |
| i | 0-based column index |
SQLITE_INTEGER=1, SQLITE_FLOAT=2, SQLITE_TEXT=3, SQLITE_BLOB=4, SQLITE_NULL=5.
(col-type stmt 0) ; => 1 (SQLITE_INTEGER)
Since: P2
row-get
(row-get [row :int name :cstr] :cstr)
look up a column value by name in a db-query row alist.
| row | row alist from db-query (cons list of alternating name/value pairs) | |
| name | column name to find |
Column value as :cstr, or "" if the name is not present.
(row-get row "name") ; => "Alice"
Since: P2
row-keys
(row-keys [row :int] :int)
return a forward cons list of column names for a db-query row alist.
| row | row alist from db-query |
Cons list of column name :cstr values (stored as :int); nil if row is empty.
(row-keys row) ; => ("id" "name" "age")
Since: P2