API for sql - clojure-contrib v1.1 (stable)

by Stephen C. Gilardi

clojure-contrib is now deprecated

clojure-contrib is no longer being developed or maintained.

Rather than a single, monolithic, contributions library, Clojure now has a set of separate libraries for each unit of functionality. The libraries are in the Clojure GitHub organization at https://github.com/clojure. API documentation of the libraries can be found at https://clojure.github.io.

If you're looking for a specific function or namespace from the old clojure-contrib, see "Where Did Clojure.Contrib Go".


Full namespace name: clojure.contrib.sql

Overview

A Clojure interface to sql databases via jdbc

See clojure.contrib.sql.test for an example
See also: Example code

Public Variables and Functions



connection

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (connection)
Returns the current database connection (or throws if there is none)
Source


create-table

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (create-table name & specs)
Creates a table on the open database connection given a table name and
specs. Each spec is either a column spec: a vector containing a column
name and optionally a type and other constraints, or a table-level
constraint: a vector containing words that express the constraint. All
words used to describe the table may be supplied as strings or keywords.
Source


delete-rows

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (delete-rows table where-params)
Deletes rows from a table. where-params is a vector containing a string
providing the (optionally parameterized) selection criteria followed by
values for any parameters.
Source


do-commands

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (do-commands & commands)
Executes SQL commands on the open database connection.
Source


do-prepared

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (do-prepared sql & param-groups)
Executes an (optionally parameterized) SQL prepared statement on the
open database connection. Each param-group is a seq of values for all of
the parameters.
Source


drop-table

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (drop-table name)
Drops a table on the open database connection given its name, a string
or keyword
Source


find-connection

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (find-connection)
Returns the current database connection (or nil if there is none)
Source


insert-records

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (insert-records table & records)
Inserts records into a table. records are maps from strings or
keywords (identifying columns) to values.
Source


insert-rows

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (insert-rows table & rows)
Inserts complete rows into a table. Each row is a vector of values for
each of the table's columns in order.
Source


insert-values

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (insert-values table column-names & value-groups)
Inserts rows into a table with values for specified columns only.
column-names is a vector of strings or keywords identifying columns. Each
value-group is a vector containing a values for each column in
order. When inserting complete rows (all columns), consider using
insert-rows instead.
Source


is-rollback-only

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (is-rollback-only)
Returns true if the outermost transaction will rollback rather than
commit when complete
Source


set-rollback-only

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (set-rollback-only)
Marks the outermost transaction such that it will rollback rather than
commit when complete
Source


transaction

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (transaction & body)
Evaluates body as a transaction on the open database connection. Any
nested transactions are absorbed into the outermost transaction. By
default, all database updates are committed together as a group after
evaluating the outermost body, or rolled back on any uncaught
exception. If set-rollback-only is called within scope of the outermost
transaction, the entire transaction will be rolled back rather than
committed when complete.
Source


update-or-insert-values

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (update-or-insert-values table where-params record)
Updates values on selected rows in a table, or inserts a new row when no
existing row matches the selection criteria. where-params is a vector
containing a string providing the (optionally parameterized) selection
criteria followed by values for any parameters. record is a map from
strings or keywords (identifying columns) to updated values.
Source


update-values

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (update-values table where-params record)
Updates values on selected rows in a table. where-params is a vector
containing a string providing the (optionally parameterized) selection
criteria followed by values for any parameters. record is a map from
strings or keywords (identifying columns) to updated values.
Source


with-connection

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (with-connection db-spec & body)
Evaluates body in the context of a new connection to a database then
closes the connection. db-spec is a map containing values for one of the
following parameter sets:

Factory:
  :factory     (required) a function of one argument, a map of params
  (others)     (optional) passed to the factory function in a map

DriverManager:
  :classname   (required) a String, the jdbc driver class name
  :subprotocol (required) a String, the jdbc subprotocol
  :subname     (required) a String, the jdbc subname
  (others)     (optional) passed to the driver as properties.

DataSource:
  :datasource  (required) a javax.sql.DataSource
  :username    (optional) a String
  :password    (optional) a String, required if :username is supplied

JNDI:
  :name        (required) a String or javax.naming.Name
  :environment (optional) a java.util.Map
Source


with-query-results

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (with-query-results results sql-params & body)
Executes a query, then evaluates body with results bound to a seq of the
results. sql-params is a vector containing a string providing
the (optionally parameterized) SQL query followed by values for any
parameters.
Source

sql.internal






connection*

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (connection*)
Returns the current database connection (or throws if there is none)
Source

find-connection*

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (find-connection*)
Returns the current database connection (or nil if there is none)
Source

get-connection

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (get-connection {:keys [factory classname subprotocol subname datasource username password name environment], :as db-spec})
Creates a connection to a database. db-spec is a map containing values
for one of the following parameter sets:

Factory:
  :factory     (required) a function of one argument, a map of params
  (others)     (optional) passed to the factory function in a map

DriverManager:
  :classname   (required) a String, the jdbc driver class name
  :subprotocol (required) a String, the jdbc subprotocol
  :subname     (required) a String, the jdbc subname
  (others)     (optional) passed to the driver as properties.

DataSource:
  :datasource  (required) a javax.sql.DataSource
  :username    (optional) a String
  :password    (optional) a String, required if :username is supplied

JNDI:
  :name        (required) a String or javax.naming.Name
  :environment (optional) a java.util.Map
Source

print-sql-exception

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (print-sql-exception stream exception)
Prints the contents of an SQLException to stream
Source

print-sql-exception-chain

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (print-sql-exception-chain stream exception)
Prints a chain of SQLExceptions to stream
Source

print-update-counts

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (print-update-counts stream exception)
Prints the update counts from a BatchUpdateException to stream
Source

rollback

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (rollback)
       (rollback val)
Accessor for the rollback flag on the current connection
Source

throw-rollback

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (throw-rollback e)
Sets rollback and throws a wrapped exception
Source

transaction*

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (transaction* func)
Evaluates func as a transaction on the open database connection. Any
nested transactions are absorbed into the outermost transaction. By
default, all database updates are committed together as a group after
evaluating the outermost body, or rolled back on any uncaught
exception. If rollback is set within scope of the outermost transaction,
the entire transaction will be rolled back rather than committed when
complete.
Source

with-connection*

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (with-connection* db-spec func)
Evaluates func in the context of a new connection to a database then
closes the connection.
Source

with-query-results*

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (with-query-results* [sql & params :as sql-params] func)
Executes a query, then evaluates func passing in a seq of the results as
an argument. The first argument is a vector containing the (optionally
parameterized) sql query string followed by values for any parameters.
Source

sql.test






create-fruit

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (create-fruit)
Create a table
Source

db-batchupdate-exception

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-batchupdate-exception)
Demonstrate a batch update exception
Source

db-exception

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-exception)
Demonstrate rolling back a partially completed transaction on exception
Source

db-get-tables

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-get-tables)
Demonstrate getting table info
Source

db-grade-a

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-grade-a)
Print rows describing all grade a fruit (grade between 90 and 100)
Source

db-grade-range

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-grade-range min max)
Print rows describing fruit that are within a grade range
Source

db-read

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-read)
Read the entire fruit table
Source

db-read-all

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-read-all)
Return all the rows of the fruit table as a vector
Source

db-rollback

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-rollback)
Demonstrate a rollback-only trasaction
Source

db-sql-exception

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-sql-exception)
Demonstrate an sql exception
Source

db-update

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-update)
Update two fruits as a transaction
Source

db-update-appearance-cost

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-update-appearance-cost name appearance cost)
Update the appearance and cost of the named fruit
Source

db-update-or-insert

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-update-or-insert record)
Updates or inserts a fruit
Source

db-write

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (db-write)
Write initial values to the database as a transaction
Source

drop-fruit

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (drop-fruit)
Drop a table
Source

insert-records-fruit

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (insert-records-fruit)
Insert records, maps from keys specifying columns to values
Source

insert-rows-fruit

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (insert-rows-fruit)
Insert complete rows
Source

insert-values-fruit

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (insert-values-fruit)
Insert rows with values for only specific columns
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.