(alter-table db-handle table columns)Alter table, add column(s) table - keyword or string columns - vector of :keyword, string, vector (name, type) or map (:name, :type) Create table iff not exists. Return - void.
Alter table, add column(s) table - keyword or string columns - vector of :keyword, string, vector (name, type) or map (:name, :type) Create table iff not exists. Return - void.
(close-db db-handle)Close a DB handle (SQLiteConnection or Postgres for now, could be changed) Could contain prepared statements and meta-data in the future
Close a DB handle (SQLiteConnection or Postgres for now, could be changed) Could contain prepared statements and meta-data in the future
(column-exists? db-handle table column)Return true iff columns exists in table within db. table - keyword or string column - keyword or string
Return true iff columns exists in table within db. table - keyword or string column - keyword or string
(column-meta-data db-handle table)Return seq of column meta data, for table in db
Return seq of column meta data, for table in db
(column-name column)Return column-name as keyword for column column - either a string/keyword (then default datatype: string), or seq-of [:name :type] return vector with name and type. Used for internal map with new tables/columns within transaction.
Return column-name as keyword for column
column - either a string/keyword (then default datatype: string),
        or seq-of [:name :type]
return vector with name and type.
Used for internal map with new tables/columns within transaction.(column-with-datatype db-spec record column-name)Determine SQL datatype of column within record. Return seq of columnname and SQL-datatype. datatype could be more than one :keyword
Determine SQL datatype of column within record. Return seq of columnname and SQL-datatype. datatype could be more than one :keyword
(columns db-handle table)Return set of column names (as keywords) in table in database table can be a string or keyword. Look in both DB metadata (with query) as well as newly added tables/columns (in cache)
Return set of column names (as keywords) in table in database table can be a string or keyword. Look in both DB metadata (with query) as well as newly added tables/columns (in cache)
(create-table db-handle table columns)Create a table table: :keyword or string columns: vector of: :keyword, string, vector (name, type) or map (:name, :type). always include a generated 'id' column. return - void.
Create a table table: :keyword or string columns: vector of: :keyword, string, vector (name, type) or map (:name, :type). always include a generated 'id' column. return - void.
(current-connection db-handle)Return current connection/transaction handle, or the db-spec if none exists. Use for working within transactions.
Return current connection/transaction handle, or the db-spec if none exists. Use for working within transactions.
Mapping of java-class to conversion function wrt sql types JSR310 LocalDate and LocalDateTime are supported, no need for conversion.
Mapping of java-class to conversion function wrt sql types JSR310 LocalDate and LocalDateTime are supported, no need for conversion.
(db-value val)Convert a value to a type understood by jdbc/sql. Can also be some JSR 310 types
Convert a value to a type understood by jdbc/sql. Can also be some JSR 310 types
(db-values record)Convert values in record/map to SQL types
Convert values in record/map to SQL types
(dquoted par)Convert par to a string and surround it with double quotes. With respect to bracketed table and column names for reserved words. This seems to work both in SQLite and Postgres (Postgres does not like brackets)
Convert par to a string and surround it with double quotes. With respect to bracketed table and column names for reserved words. This seems to work both in SQLite and Postgres (Postgres does not like brackets)
(dquoted-record record)Convert keys in record/map to string and surround with double quotes. Wrt using reserved words in the table. Maybe only do this for the list of 145 (SQlite) reserved words
Convert keys in record/map to string and surround with double quotes. Wrt using reserved words in the table. Maybe only do this for the list of 145 (SQlite) reserved words
(exec db-handle sql)(exec db-handle sql params)Execute a DDL/DML query. Also handle optional params-sequence given.
Execute a DDL/DML query. Also handle optional params-sequence given.
(get-first-id db-handle res)Return created id of first row of result-set. This is different for SQLite and Postgres
Return created id of first row of result-set. This is different for SQLite and Postgres
(id-spec handle)Generate id-column spec for database type, given db handle
Generate id-column spec for database type, given db handle
(in-transaction handle & body)Run nested expressions in a transaction based on handle. Works in conjunction with set-transaction and current-transaction. Returns result of last expression
Run nested expressions in a transaction based on handle. Works in conjunction with set-transaction and current-transaction. Returns result of last expression
(in-transaction? db-handle)Return true if handle is currently within a transaction
Return true if handle is currently within a transaction
(insert db-handle table record)Insert record into table, adding table/columns if needed. Default/pessimistic version: first check if table and columns exist and create/alter table where needed; then insert record. Also call db-values on record.
Insert record into table, adding table/columns if needed. Default/pessimistic version: first check if table and columns exist and create/alter table where needed; then insert record. Also call db-values on record.
(insert-no-check db-handle table record)Insert record into table, no checks if table/columns exist. Return generated id.
Insert record into table, no checks if table/columns exist. Return generated id.
(insert-opt db-handle table record)Insert record into table, adding table/columns if needed. Optimistic version: first try to insert; if fails, add table/column(s) and try again. This version might be faster, need some tests.
Insert record into table, adding table/columns if needed. Optimistic version: first try to insert; if fails, add table/column(s) and try again. This version might be faster, need some tests.
(log! arg)(log! msg arg)Log argument to stdout and return it
Log argument to stdout and return it
(map-kv f coll)Apply f to very val in coll, return result
Apply f to very val in coll, return result
(map-kv-key f coll)Apply f to every key in coll, return result
Apply f to every key in coll, return result
(new-columns db-spec cols record)Determine new columns (including types) for table based on record. cols - the current columns of table (seq of keywords) record - the hashmap with needed columns of table (columns als keywords) return - seq of new columns
Determine new columns (including types) for table based on record. cols - the current columns of table (seq of keywords) record - the hashmap with needed columns of table (columns als keywords) return - seq of new columns
(open-db-spec db-spec)Open DB connection given a spec, could be SQLite or Postgresql, maybe others
Open DB connection given a spec, could be SQLite or Postgresql, maybe others
(open-db-sqlite db-name)Open SQLite DB and return handle (SQLiteConnection for now, could be changed. Return connection both directly in map as within returned db-spec within map. db-name - path to DB, existing or new, as string
Open SQLite DB and return handle (SQLiteConnection for now, could be changed. Return connection both directly in map as within returned db-spec within map. db-name - path to DB, existing or new, as string
(query db-handle sql)(query db-handle sql params)Perform a SQL (select) query, return sequence of maps. Also handle optional params-sequence given.
Perform a SQL (select) query, return sequence of maps. Also handle optional params-sequence given.
(set-init-function db-handle f)Set a function to be executed on each new connection/transaction. Function should accept one parameter, the db handle.
Set a function to be executed on each new connection/transaction. Function should accept one parameter, the db handle.
(set-transaction db-handle t-con)Mark transaction handle given by with-db-transaction in this handle. Also exec init-function on this transaction iff it is set. Keep list of new tables/columns created in this transaction. Also call :init-function when given (eg. for percentile function). Fail if transaction already started
Mark transaction handle given by with-db-transaction in this handle. Also exec init-function on this transaction iff it is set. Keep list of new tables/columns created in this transaction. Also call :init-function when given (eg. for percentile function). Fail if transaction already started
(sql-db-type db-spec value)Determine sql type of a value For now only integer, float, string and date-time types for Postgres. Default to varchar if no match. sql-type dependent on db-spec, eg with date/time values. throws an exception if type cannot be determined. (maybe should return varchar in that case)
Determine sql type of a value For now only integer, float, string and date-time types for Postgres. Default to varchar if no match. sql-type dependent on db-spec, eg with date/time values. throws an exception if type cannot be determined. (maybe should return varchar in that case)
SQL types for combinations of database and Clojure/Java values Includes defaults per datatype and also per database type.
SQL types for combinations of database and Clojure/Java values Includes defaults per datatype and also per database type.
(surround-brackets par)Convert par to a string and surround it with brackets. Wrt bracketed table and column names for reserved words
Convert par to a string and surround it with brackets. Wrt bracketed table and column names for reserved words
(table-exists? db-handle table)Given db-handle and table, returns true iff table exists within DB, false otherwise. Table can be keyword or string.
Given db-handle and table, returns true iff table exists within DB, false otherwise. Table can be keyword or string.
(table-meta-data db-handle)Return seq of table meta data, but for now without column info
Return seq of table meta data, but for now without column info
(tables db-handle)Return sequence of table names (as keywords) in database.
Return sequence of table names (as keywords) in database.
(unset-transaction db-handle)Unmark transaction handle given by with-db-transaction in this handle. Reset new columns/tables, should be available als meta-data after commit. Fail if no transaction started
Unmark transaction handle given by with-db-transaction in this handle. Reset new columns/tables, should be available als meta-data after commit. Fail if no transaction started
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs | 
| ← | Move to previous article | 
| → | Move to next article | 
| Ctrl+/ | Jump to the search field |