The cl-dbi Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-dbi Reference Manual

This is the cl-dbi Reference Manual, version 0.9.4, generated automatically by Declt version 3.0 "Montgomery Scott" on Wed Mar 25 17:12:28 2020 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

CL-DBI - Database-independent interface for Common Lisp

Build Status

Usage

Connecting - MYSQL

(defvar *connection*
  (dbi:connect :mysql
               :database-name "test"
               :username "nobody"
               :password "1234"))

Connecting - SQLite

 (defvar *connection*
  (dbi:connect :sqlite3
               :database-name "/home/gt/test.sqlite3"))

Executing a query

(let* ((query (dbi:prepare *connection*
                           "SELECT * FROM somewhere WHERE flag = ? OR updated_at > ?"))
       (query (dbi:execute query (list 0 "2011-11-01"))))
  (loop for row = (dbi:fetch query)
        while row
        ;; process "row".
        ))

;; Do it all at once
(dbi:fetch-all (dbi:execute (dbi:prepare *connection* "SELECT * FROM somewhere WHERE flag = ? OR updated_at > ?")
                            (list 0 "2011-11-01")))

dbi:do-sql is another option that prepares and executes a single statement. It returns the number of rows affected. It's typically used for non-SELECT statements.

(dbi:do-sql *connection*
            "INSERT INTO somewhere (flag, updated_at) VALUES (?, NOW())"
            (list 0))
;=> 1

Using dbi:with-connection to ensure connections are closed

(dbi:with-connection (conn :sqlite3 :database-name "/home/fukamachi/test.db")
  (let* ((query (dbi:prepare conn "SELECT * FROM People"))
         (query (dbi:execute query)))
    (loop for row = (dbi:fetch query)
          while row
          do (format t "~A~%" row))))

Connection pooling

dbi:connect-cached returns a existing connection if the database is already connected. Since one cache will be created for each thread, it's safe to use in a multithread application.

Description

CL-DBI provides a uniform interface for many SQL databases, so you need not learn a separate API for each database.

This library is especially convenient when you want to use different databases in different environments. For example, you moght use MySQL as a production database, but use SQLite3 on your development system. To switch database backends you need only change the arguments to dbi:connect.

Databases

Installation

This library is available on Quicklisp.

CL-USER> (ql:quickload :cl-dbi)
To load "cl-dbi":
  Load 1 ASDF system:
    cl-dbi
; Loading "cl-dbi"

(:CL-DBI)

API

User-Level API

Driver-Level API

Creating a new driver

Create a subclass of <dbi-driver> and implement following methods.

These methods can be overriden if needed.

Hook of SQL execution

CL-DBI provides dbi:*sql-execution-hooks*, a hook to run for each SQL execution, particularly used for logging.

The hook function takes these 4 values:

The row count and its execution time can be null, if those values are not available for the driver for some reason.

dbi:simple-sql-logger is also provided for printing those values directly to *standard-output*. It can be enabled as so:

(push #'dbi:simple-sql-logger dbi:*sql-execution-hooks*)

Development

Running all tests in the Docker

This will not require you to install Postgres or Mysql. All you need is Docker and Docker Compose.

To run all tests, execute this in the shell:

docker-compose up tests

Running specific driver's unittests

Running tests with docker-compose does not allow you to debug code in SLIME or SLY. To do this, you need to start databases as separate containers and to make their ports available to the host machine.

Here is how you can start Postgres and Mysql in Docker and run unittests agains them:

Author

Copyright

Copyright (c) 2011 Eitaro Fukamachi (e.arrows@gmail.com)

License

Licensed under the LLGPL License.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Next: , Previous: , Up: Systems   [Contents][Index]

2.1 cl-dbi

Author

Eitaro Fukamachi

License

LLGPL

Version

0.9.4

Dependency

dbi (system)

Source

cl-dbi.asd (file)


Previous: , Up: Systems   [Contents][Index]

2.2 dbi

Author

Eitaro Fukamachi

License

LLGPL

Description

Database independent interface for Common Lisp

Version

0.9.4

Dependencies
Source

dbi.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 dbi/src

Dependency

src/utils.lisp (file)

Parent

dbi (system)

Location

src/

Components

Next: , Previous: , Up: Top   [Contents][Index]

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 cl-dbi.asd

Location

cl-dbi.asd

Systems

cl-dbi (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.2 dbi.asd

Location

dbi.asd

Systems

dbi (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.3 dbi/src/dbi.lisp

Dependencies
Parent

src (module)

Location

src/dbi.lisp

Packages

dbi

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.4 dbi/src/driver.lisp

Dependency

error.lisp (file)

Parent

src (module)

Location

src/driver.lisp

Packages

dbi.driver

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.5 dbi/src/logger.lisp

Parent

src (module)

Location

src/logger.lisp

Packages

dbi.logger

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.6 dbi/src/error.lisp

Parent

src (module)

Location

src/error.lisp

Packages

dbi.error

Exported Definitions

Previous: , Up: Lisp files   [Contents][Index]

4.1.7 dbi/src/utils.lisp

Parent

dbi (system)

Location

src/utils.lisp

Packages

dbi.utils

Exported Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 dbi

Source

dbi.lisp (file)

Nickname

cl-dbi

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

5.2 dbi.driver

Source

driver.lisp (file)

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

5.3 dbi.logger

Source

logger.lisp (file)

Use List

common-lisp

Exported Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

5.4 dbi.error

Source

error.lisp (file)

Use List
Used By List

dbi

Exported Definitions

Previous: , Up: Packages   [Contents][Index]

5.5 dbi.utils

Source

src/utils.lisp (file)

Use List

common-lisp

Used By List
Exported Definitions

Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Special variables

Special Variable: *sql-execution-hooks*
Package

dbi.logger

Source

logger.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.2 Macros

Macro: defclass/a NAME SUPERCLASSES SLOTS &rest CLASS-OPTIONS
Package

dbi.utils

Source

src/utils.lisp (file)

Macro: define-condition/a NAME PARENT-TYPES SLOTS &body OPTIONS
Package

dbi.utils

Source

src/utils.lisp (file)

Macro: with-connection (CONN-SYM &rest REST) &body BODY
Package

dbi

Source

dbi.lisp (file)

Macro: with-savepoint CONN &body BODY
Package

dbi.driver

Source

driver.lisp (file)

Macro: with-took-ms TOOK-MS &body BODY
Package

dbi.logger

Source

logger.lisp (file)

Macro: with-transaction CONN &body BODY

Start a transaction and commit at the end of this block. If the evaluation ‘body‘ is interrupted, the transaction is rolled back automatically.

Package

dbi.driver

Source

driver.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.3 Functions

Function: connect DRIVER-NAME &rest PARAMS &key DATABASE-NAME &allow-other-keys

Open a connection to the database which corresponds to ‘driver-name‘.

Package

dbi

Source

dbi.lisp (file)

Function: connect-cached &rest CONNECT-ARGS
Package

dbi

Source

dbi.lisp (file)

Function: find-driver DRIVER-NAME

Find a driver class named as ‘driver-name‘.
‘driver-name‘ is a string designer.
Driver should be named like ’DBD-SOMETHING’ for a database ’something’.

Package

dbi.driver

Source

driver.lisp (file)

Function: in-transaction CONN

Returns True if called inside a transaction block.

Package

dbi.driver

Source

driver.lisp (file)

Function: list-all-drivers ()

Return a list of direct subclasses for ‘dbi-driver‘.

Package

dbi.driver

Source

driver.lisp (file)

Function: simple-sql-logger SQL PARAMS ROW-COUNT TOOK-MS
Package

dbi.logger

Source

logger.lisp (file)

Function: sql-log SQL PARAMS ROW-COUNT TOOK-MS
Package

dbi.logger

Source

logger.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.4 Generic functions

Generic Function: begin-transaction CONN

Start a transaction.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: begin-transaction (CONN dbi-connection) around

Turn ‘auto-commit‘ off automatically before starting a transaction.

Method: begin-transaction (CONN dbi-connection)
Generic Function: commit CONN

Commit changes and end the current transaction.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: commit (CONN dbi-connection)
Method: commit (CONN dbi-connection) around
Generic Function: connection-database-name OBJECT
Generic Function: (setf connection-database-name) NEW-VALUE OBJECT
Package

dbi.driver

Methods
Method: connection-database-name (DBI-CONNECTION dbi-connection)

automatically generated reader method

Source

driver.lisp (file)

Method: (setf connection-database-name) NEW-VALUE (DBI-CONNECTION dbi-connection)

automatically generated writer method

Source

driver.lisp (file)

Generic Function: connection-driver-type CONN
Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: connection-driver-type (CONN dbi-connection)
Generic Function: connection-handle OBJECT
Generic Function: (setf connection-handle) NEW-VALUE OBJECT
Package

dbi.driver

Methods
Method: connection-handle (DBI-CONNECTION dbi-connection)

automatically generated reader method

Source

driver.lisp (file)

Method: (setf connection-handle) NEW-VALUE (DBI-CONNECTION dbi-connection)

automatically generated writer method

Source

driver.lisp (file)

Generic Function: disconnect CONN
Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: disconnect (CONN dbi-connection)
Generic Function: do-sql CONN SQL &optional PARAMS

Do preparation and execution at once. This method may be overrided by subclasses.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: do-sql (CONN dbi-connection) (SQL string) &optional PARAMS
Method: do-sql (CONN dbi-connection) SQL &optional PARAMS around
Generic Function: escape-sql CONN SQL

Return escaped ‘sql‘.
This method may be overrided by subclasses when needed.
For example, in case of MySQL and PostgreSQL, backslashes must be escaped by doubling it.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: escape-sql (CONN dbi-connection) (SQL string)
Generic Function: execute QUERY &optional PARAMS

Execute ‘query‘ with ‘params‘ and return the results.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: execute (QUERY dbi-query) &optional PARAMS
Generic Function: execute-using-connection CONN QUERY PARAMS

Execute ‘query‘ in ‘conn‘.
This method must be implemented in each drivers.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: execute-using-connection (CONN dbi-connection) (QUERY dbi-query) PARAMS
Generic Function: fetch QUERY

Fetch the first row from ‘query‘ which is returned by ‘execute‘.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: fetch (QUERY dbi-query)
Generic Function: fetch-all QUERY

Fetch all rest rows from ‘query‘.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: fetch-all (QUERY dbi-query)
Generic Function: fetch-using-connection CONN QUERY
Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: fetch-using-connection (CONN dbi-connection) (QUERY dbi-query)
Generic Function: free-query-resources QUERY

Free the resources (e.g. foreign, heap allocated
memory) associated with this query. This method is specialized and effective (and should matches each ’prepare’ function call) only for dbd-sqlite3-query. The default method currently has empty body.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: free-query-resources QUERY
Generic Function: make-connection DRIVER &key

Create a instance of ‘dbi-connection‘ for the ‘driver‘. This method must be implemented in each drivers.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: make-connection (DRIVER dbi-driver) &key
Generic Function: ping CONN

Check if the database server is still running and the connection to it is still working.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: ping (CONN dbi-connection)
Generic Function: prepare CONN SQL &key QUERY-CLASS
Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: prepare (CONN dbi-connection) (SQL string) &key QUERY-CLASS

Preparing executing SQL statement and returns a instance of ‘dbi-query‘. This method may be overrided by subclasses.

Generic Function: query-connection OBJECT
Generic Function: (setf query-connection) NEW-VALUE OBJECT
Package

dbi.driver

Methods
Method: query-connection (DBI-QUERY dbi-query)

automatically generated reader method

Source

driver.lisp (file)

Method: (setf query-connection) NEW-VALUE (DBI-QUERY dbi-query)

automatically generated writer method

Source

driver.lisp (file)

Generic Function: query-prepared OBJECT
Generic Function: (setf query-prepared) NEW-VALUE OBJECT
Package

dbi.driver

Methods
Method: query-prepared (DBI-QUERY dbi-query)

automatically generated reader method

Source

driver.lisp (file)

Method: (setf query-prepared) NEW-VALUE (DBI-QUERY dbi-query)

automatically generated writer method

Source

driver.lisp (file)

Generic Function: query-results OBJECT
Generic Function: (setf query-results) NEW-VALUE OBJECT
Package

dbi.driver

Methods
Method: query-results (DBI-QUERY dbi-query)

automatically generated reader method

Source

driver.lisp (file)

Method: (setf query-results) NEW-VALUE (DBI-QUERY dbi-query)

automatically generated writer method

Source

driver.lisp (file)

Generic Function: query-row-count OBJECT
Generic Function: (setf query-row-count) NEW-VALUE OBJECT
Package

dbi.driver

Methods
Method: query-row-count (DBI-QUERY dbi-query)

automatically generated reader method

Source

driver.lisp (file)

Method: (setf query-row-count) NEW-VALUE (DBI-QUERY dbi-query)

automatically generated writer method

Source

driver.lisp (file)

Generic Function: query-sql OBJECT
Generic Function: (setf query-sql) NEW-VALUE OBJECT
Package

dbi.driver

Methods
Method: query-sql (DBI-QUERY dbi-query)

automatically generated reader method

Source

driver.lisp (file)

Method: (setf query-sql) NEW-VALUE (DBI-QUERY dbi-query)

automatically generated writer method

Source

driver.lisp (file)

Generic Function: release-savepoint CONN &optional IDENTIFIER
Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: release-savepoint (CONN dbi-connection) &optional IDENTIFIER
Method: release-savepoint (CONN dbi-connection) &optional IDENTIFIER around
Generic Function: rollback CONN

Rollback all changes and end the current transaction.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: rollback (CONN dbi-connection)
Method: rollback (CONN dbi-connection) around
Generic Function: rollback-savepoint CONN &optional IDENTIFIER
Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: rollback-savepoint (CONN dbi-connection) &optional IDENTIFIER
Method: rollback-savepoint (CONN dbi-connection) &optional IDENTIFIER around
Generic Function: row-count CONN

Return the number of counts modified by the last executed INSERT/UPDATE/DELETE query.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: row-count (CONN dbi-connection)
Generic Function: savepoint CONN IDENTIFIER
Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: savepoint (CONN dbi-connection) IDENTIFIER

Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.5 Conditions

Condition: <dbi-already-commited-error> ()

This exception occur when there is a programming error and you are trying to commit a transaction twice.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-error (condition)

Condition: <dbi-already-rolled-back-error> ()

This exception occur when there is a programming error and you are trying to rollback a transaction twice.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-error (condition)

Condition: <dbi-data-error> ()

Exception for errors due to problems with the processed
data such as division for zero, numeric value out of range, etc.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-database-error (condition)

Condition: <dbi-database-error> ()

Exception for errors related to the database.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-error (condition)

Direct subclasses
Direct slots
Slot: message
Initargs

:message

Slot: error-code
Initargs

:error-code

Condition: <dbi-error> ()

Base class of all other error exceptions. Use this to catch all DBI errors.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

simple-error (condition)

Direct subclasses
Condition: <dbi-integrity-error> ()

Exception raised when the relational integrity of the database is affected, e.g. a foreign key check fails.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-database-error (condition)

Condition: <dbi-interface-error> ()

Exception for errors related to the DBI interface rather than the database itself.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-error (condition)

Direct subclasses

dbi-unimplemented-error (condition)

Condition: <dbi-internal-error> ()

Exception raised when the database encounters an internal error, e.g. the cursor is not valid anymore, the transaction is out of sync.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-database-error (condition)

Condition: <dbi-notsupported-error> ()

Exception raised if e.g. commit() is called for a database which do not support transactions.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-database-error (condition)

Direct slots
Slot: method-name
Initargs

:method-name

Condition: <dbi-operational-error> ()

Exception for errors related to the database’s operation which are not necessarily under the control of the programmer. This includes such things as unexpected disconnect, datasource name not found, transaction could not be processed, a memory allocation error occured during processing, etc.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-database-error (condition)

Condition: <dbi-programming-error> ()

Exception raised for programming errors, e.g. table not found or already exists, syntax error in SQL statement, wrong number of parameters specified, etc.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-database-error (condition)

Condition: <dbi-unimplemented-error> ()

Exception raised if the DBD driver has not specified a mandatory method.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-interface-error (condition)

Direct slots
Slot: method-name
Initargs

:method-name

Condition: <dbi-warning> ()

For important warnings like data truncation, etc.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

simple-warning (condition)

Condition: dbi-already-commited-error ()

This exception occur when there is a programming error and you are trying to commit a transaction twice.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-error (condition)

Condition: dbi-already-rolled-back-error ()

This exception occur when there is a programming error and you are trying to rollback a transaction twice.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-error (condition)

Condition: dbi-data-error ()

Exception for errors due to problems with the processed
data such as division for zero, numeric value out of range, etc.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-database-error (condition)

Condition: dbi-database-error ()

Exception for errors related to the database.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-error (condition)

Direct subclasses
Direct slots
Slot: message
Initargs

:message

Slot: error-code
Initargs

:error-code

Condition: dbi-error ()

Base class of all other error exceptions. Use this to catch all DBI errors.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

simple-error (condition)

Direct subclasses
Condition: dbi-integrity-error ()

Exception raised when the relational integrity of the database is affected, e.g. a foreign key check fails.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-database-error (condition)

Condition: dbi-interface-error ()

Exception for errors related to the DBI interface rather than the database itself.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-error (condition)

Direct subclasses

dbi-unimplemented-error (condition)

Condition: dbi-internal-error ()

Exception raised when the database encounters an internal error, e.g. the cursor is not valid anymore, the transaction is out of sync.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-database-error (condition)

Condition: dbi-notsupported-error ()

Exception raised if e.g. commit() is called for a database which do not support transactions.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-database-error (condition)

Direct slots
Slot: method-name
Initargs

:method-name

Condition: dbi-operational-error ()

Exception for errors related to the database’s operation which are not necessarily under the control of the programmer. This includes such things as unexpected disconnect, datasource name not found, transaction could not be processed, a memory allocation error occured during processing, etc.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-database-error (condition)

Condition: dbi-programming-error ()

Exception raised for programming errors, e.g. table not found or already exists, syntax error in SQL statement, wrong number of parameters specified, etc.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-database-error (condition)

Condition: dbi-unimplemented-error ()

Exception raised if the DBD driver has not specified a mandatory method.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

dbi-interface-error (condition)

Direct slots
Slot: method-name
Initargs

:method-name

Condition: dbi-warning ()

For important warnings like data truncation, etc.

Package

dbi.error

Source

error.lisp (file)

Direct superclasses

simple-warning (condition)


Previous: , Up: Exported definitions   [Contents][Index]

6.1.6 Classes

Class: <dbi-connection> ()

Base class for managing DB connection.

Package

dbi.driver

Source

driver.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: auto-commit
Type

boolean

Initargs

:auto-commit

Initform

t

Slot: database-name
Initargs

:database-name

Readers

connection-database-name (generic function)

Writers

(setf connection-database-name) (generic function)

Slot: %handle
Initargs

:handle

Readers

connection-handle (generic function)

Writers

(setf connection-handle) (generic function)

Class: <dbi-driver> ()

Base class for DB driver.

Package

dbi.driver

Source

driver.lisp (file)

Direct superclasses

standard-object (class)

Direct methods

make-connection (method)

Class: <dbi-query> ()

Class that represents a prepared DB query.

Package

dbi.driver

Source

driver.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: connection
Type

dbi.driver:dbi-connection

Initargs

:connection

Readers

query-connection (generic function)

Writers

(setf query-connection) (generic function)

Slot: sql
Type

string

Initargs

:sql

Readers

query-sql (generic function)

Writers

(setf query-sql) (generic function)

Slot: prepared
Initargs

:prepared

Readers

query-prepared (generic function)

Writers

(setf query-prepared) (generic function)

Slot: results
Initargs

:results

Readers

query-results (generic function)

Writers

(setf query-results) (generic function)

Slot: row-count
Type

(or integer null)

Initargs

:row-count

Readers

query-row-count (generic function)

Writers

(setf query-row-count) (generic function)

Class: dbi-connection ()

Base class for managing DB connection.

Package

dbi.driver

Source

driver.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: auto-commit
Type

boolean

Initargs

:auto-commit

Initform

t

Slot: database-name
Initargs

:database-name

Readers

connection-database-name (generic function)

Writers

(setf connection-database-name) (generic function)

Slot: %handle
Initargs

:handle

Readers

connection-handle (generic function)

Writers

(setf connection-handle) (generic function)

Class: dbi-driver ()

Base class for DB driver.

Package

dbi.driver

Source

driver.lisp (file)

Direct superclasses

standard-object (class)

Direct methods

make-connection (method)

Class: dbi-query ()

Class that represents a prepared DB query.

Package

dbi.driver

Source

driver.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: connection
Type

dbi.driver:dbi-connection

Initargs

:connection

Readers

query-connection (generic function)

Writers

(setf query-connection) (generic function)

Slot: sql
Type

string

Initargs

:sql

Readers

query-sql (generic function)

Writers

(setf query-sql) (generic function)

Slot: prepared
Initargs

:prepared

Readers

query-prepared (generic function)

Writers

(setf query-prepared) (generic function)

Slot: results
Initargs

:results

Readers

query-results (generic function)

Writers

(setf query-results) (generic function)

Slot: row-count
Type

(or integer null)

Initargs

:row-count

Readers

query-row-count (generic function)

Writers

(setf query-row-count) (generic function)


Previous: , Up: Definitions   [Contents][Index]

6.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.1 Special variables

Special Variable: *connection-pool-cleanup-lock*
Package

dbi

Source

dbi.lisp (file)

Special Variable: *threads-connection-pool*
Package

dbi

Source

dbi.lisp (file)

Special Variable: *transaction-state*

A stack of transaction and savepoint states.

Package

dbi.driver

Source

driver.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.2 Macros

Macro: %with-transaction CONN &body BODY
Package

dbi.driver

Source

driver.lisp (file)

Macro: finalize-savepoint NEW-STATE &body BODY
Package

dbi.driver

Source

driver.lisp (file)

Macro: with-retrying &body BODY
Package

dbi

Source

dbi.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.3 Functions

Function: assert-transaction-is-in-progress TRANSACTION-STATE
Package

dbi.driver

Source

driver.lisp (file)

Function: cleanup-connection-pool ()
Package

dbi

Source

dbi.lisp (file)

Function: generate-random-savepoint ()
Package

dbi.driver

Source

driver.lisp (file)

Function: get-connection-pool ()
Package

dbi

Source

dbi.lisp (file)

Function: get-transaction-state CONN

Returns an object representing transaction’s state
if called inside a transaction block or nil otherwise.

Package

dbi.driver

Source

driver.lisp (file)

Function: load-driver DRIVER-NAME
Package

dbi

Source

dbi.lisp (file)

Function: make-connection-pool ()
Package

dbi

Source

dbi.lisp (file)

Function: make-threads-connection-pool ()
Package

dbi

Source

dbi.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.4 Generic functions

Generic Function: get-conn OBJECT
Package

dbi.driver

Methods
Method: get-conn (TRANSACTION-STATE transaction-state)

automatically generated reader method

Source

driver.lisp (file)

Generic Function: get-identifier OBJECT
Package

dbi.driver

Methods
Method: get-identifier (SAVEPOINT-STATE savepoint-state)

automatically generated reader method

Source

driver.lisp (file)

Generic Function: get-state OBJECT
Generic Function: (setf get-state) NEW-VALUE OBJECT
Package

dbi.driver

Methods
Method: get-state (TRANSACTION-STATE transaction-state)

automatically generated reader method

Source

driver.lisp (file)

Method: (setf get-state) NEW-VALUE (TRANSACTION-STATE transaction-state)

automatically generated writer method

Source

driver.lisp (file)

Generic Function: prepare-sql CONN SQL

Create a function that takes parameters, binds them into a query and returns SQL as a string.

Package

dbi.driver

Source

driver.lisp (file)

Methods
Method: prepare-sql (CONN dbi-connection) (SQL string)

Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.5 Conditions

Condition: transaction-done-condition ()
Package

dbi.driver

Source

driver.lisp (file)

Direct superclasses

condition (condition)


Previous: , Up: Internal definitions   [Contents][Index]

6.2.6 Classes

Class: savepoint-state ()
Package

dbi.driver

Source

driver.lisp (file)

Direct superclasses

transaction-state (class)

Direct methods

get-identifier (method)

Direct slots
Slot: identifier
Type

string

Initform

(dbi.driver::generate-random-savepoint)

Readers

get-identifier (generic function)

Class: transaction-state ()
Package

dbi.driver

Source

driver.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses

savepoint-state (class)

Direct methods
Direct slots
Slot: conn
Type

dbi.driver:dbi-connection

Initargs

:conn

Readers

get-conn (generic function)

Slot: state
Type

(member :in-progress :commited :rolled-back)

Initform

:in-progress

Readers

get-state (generic function)

Writers

(setf get-state) (generic function)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   D   F   L   M  
Index Entry  Section

C
cl-dbi.asd: The cl-dbi․asd file

D
dbi.asd: The dbi․asd file
dbi/src: The dbi/src module
dbi/src/dbi.lisp: The dbi/src/dbi․lisp file
dbi/src/driver.lisp: The dbi/src/driver․lisp file
dbi/src/error.lisp: The dbi/src/error․lisp file
dbi/src/logger.lisp: The dbi/src/logger․lisp file
dbi/src/utils.lisp: The dbi/src/utils․lisp file

F
File, Lisp, cl-dbi.asd: The cl-dbi․asd file
File, Lisp, dbi.asd: The dbi․asd file
File, Lisp, dbi/src/dbi.lisp: The dbi/src/dbi․lisp file
File, Lisp, dbi/src/driver.lisp: The dbi/src/driver․lisp file
File, Lisp, dbi/src/error.lisp: The dbi/src/error․lisp file
File, Lisp, dbi/src/logger.lisp: The dbi/src/logger․lisp file
File, Lisp, dbi/src/utils.lisp: The dbi/src/utils․lisp file

L
Lisp File, cl-dbi.asd: The cl-dbi․asd file
Lisp File, dbi.asd: The dbi․asd file
Lisp File, dbi/src/dbi.lisp: The dbi/src/dbi․lisp file
Lisp File, dbi/src/driver.lisp: The dbi/src/driver․lisp file
Lisp File, dbi/src/error.lisp: The dbi/src/error․lisp file
Lisp File, dbi/src/logger.lisp: The dbi/src/logger․lisp file
Lisp File, dbi/src/utils.lisp: The dbi/src/utils․lisp file

M
Module, dbi/src: The dbi/src module

Jump to:   C   D   F   L   M  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %   (  
A   B   C   D   E   F   G   I   L   M   P   Q   R   S   W  
Index Entry  Section

%
%with-transaction: Internal macros

(
(setf connection-database-name): Exported generic functions
(setf connection-database-name): Exported generic functions
(setf connection-handle): Exported generic functions
(setf connection-handle): Exported generic functions
(setf get-state): Internal generic functions
(setf get-state): Internal generic functions
(setf query-connection): Exported generic functions
(setf query-connection): Exported generic functions
(setf query-prepared): Exported generic functions
(setf query-prepared): Exported generic functions
(setf query-results): Exported generic functions
(setf query-results): Exported generic functions
(setf query-row-count): Exported generic functions
(setf query-row-count): Exported generic functions
(setf query-sql): Exported generic functions
(setf query-sql): Exported generic functions

A
assert-transaction-is-in-progress: Internal functions

B
begin-transaction: Exported generic functions
begin-transaction: Exported generic functions
begin-transaction: Exported generic functions

C
cleanup-connection-pool: Internal functions
commit: Exported generic functions
commit: Exported generic functions
commit: Exported generic functions
connect: Exported functions
connect-cached: Exported functions
connection-database-name: Exported generic functions
connection-database-name: Exported generic functions
connection-driver-type: Exported generic functions
connection-driver-type: Exported generic functions
connection-handle: Exported generic functions
connection-handle: Exported generic functions

D
defclass/a: Exported macros
define-condition/a: Exported macros
disconnect: Exported generic functions
disconnect: Exported generic functions
do-sql: Exported generic functions
do-sql: Exported generic functions
do-sql: Exported generic functions

E
escape-sql: Exported generic functions
escape-sql: Exported generic functions
execute: Exported generic functions
execute: Exported generic functions
execute-using-connection: Exported generic functions
execute-using-connection: Exported generic functions

F
fetch: Exported generic functions
fetch: Exported generic functions
fetch-all: Exported generic functions
fetch-all: Exported generic functions
fetch-using-connection: Exported generic functions
fetch-using-connection: Exported generic functions
finalize-savepoint: Internal macros
find-driver: Exported functions
free-query-resources: Exported generic functions
free-query-resources: Exported generic functions
Function, assert-transaction-is-in-progress: Internal functions
Function, cleanup-connection-pool: Internal functions
Function, connect: Exported functions
Function, connect-cached: Exported functions
Function, find-driver: Exported functions
Function, generate-random-savepoint: Internal functions
Function, get-connection-pool: Internal functions
Function, get-transaction-state: Internal functions
Function, in-transaction: Exported functions
Function, list-all-drivers: Exported functions
Function, load-driver: Internal functions
Function, make-connection-pool: Internal functions
Function, make-threads-connection-pool: Internal functions
Function, simple-sql-logger: Exported functions
Function, sql-log: Exported functions

G
generate-random-savepoint: Internal functions
Generic Function, (setf connection-database-name): Exported generic functions
Generic Function, (setf connection-handle): Exported generic functions
Generic Function, (setf get-state): Internal generic functions
Generic Function, (setf query-connection): Exported generic functions
Generic Function, (setf query-prepared): Exported generic functions
Generic Function, (setf query-results): Exported generic functions
Generic Function, (setf query-row-count): Exported generic functions
Generic Function, (setf query-sql): Exported generic functions
Generic Function, begin-transaction: Exported generic functions
Generic Function, commit: Exported generic functions
Generic Function, connection-database-name: Exported generic functions
Generic Function, connection-driver-type: Exported generic functions
Generic Function, connection-handle: Exported generic functions
Generic Function, disconnect: Exported generic functions
Generic Function, do-sql: Exported generic functions
Generic Function, escape-sql: Exported generic functions
Generic Function, execute: Exported generic functions
Generic Function, execute-using-connection: Exported generic functions
Generic Function, fetch: Exported generic functions
Generic Function, fetch-all: Exported generic functions
Generic Function, fetch-using-connection: Exported generic functions
Generic Function, free-query-resources: Exported generic functions
Generic Function, get-conn: Internal generic functions
Generic Function, get-identifier: Internal generic functions
Generic Function, get-state: Internal generic functions
Generic Function, make-connection: Exported generic functions
Generic Function, ping: Exported generic functions
Generic Function, prepare: Exported generic functions
Generic Function, prepare-sql: Internal generic functions
Generic Function, query-connection: Exported generic functions
Generic Function, query-prepared: Exported generic functions
Generic Function, query-results: Exported generic functions
Generic Function, query-row-count: Exported generic functions
Generic Function, query-sql: Exported generic functions
Generic Function, release-savepoint: Exported generic functions
Generic Function, rollback: Exported generic functions
Generic Function, rollback-savepoint: Exported generic functions
Generic Function, row-count: Exported generic functions
Generic Function, savepoint: Exported generic functions
get-conn: Internal generic functions
get-conn: Internal generic functions
get-connection-pool: Internal functions
get-identifier: Internal generic functions
get-identifier: Internal generic functions
get-state: Internal generic functions
get-state: Internal generic functions
get-transaction-state: Internal functions

I
in-transaction: Exported functions

L
list-all-drivers: Exported functions
load-driver: Internal functions

M
Macro, %with-transaction: Internal macros
Macro, defclass/a: Exported macros
Macro, define-condition/a: Exported macros
Macro, finalize-savepoint: Internal macros
Macro, with-connection: Exported macros
Macro, with-retrying: Internal macros
Macro, with-savepoint: Exported macros
Macro, with-took-ms: Exported macros
Macro, with-transaction: Exported macros
make-connection: Exported generic functions
make-connection: Exported generic functions
make-connection-pool: Internal functions
make-threads-connection-pool: Internal functions
Method, (setf connection-database-name): Exported generic functions
Method, (setf connection-handle): Exported generic functions
Method, (setf get-state): Internal generic functions
Method, (setf query-connection): Exported generic functions
Method, (setf query-prepared): Exported generic functions
Method, (setf query-results): Exported generic functions
Method, (setf query-row-count): Exported generic functions
Method, (setf query-sql): Exported generic functions
Method, begin-transaction: Exported generic functions
Method, begin-transaction: Exported generic functions
Method, commit: Exported generic functions
Method, commit: Exported generic functions
Method, connection-database-name: Exported generic functions
Method, connection-driver-type: Exported generic functions
Method, connection-handle: Exported generic functions
Method, disconnect: Exported generic functions
Method, do-sql: Exported generic functions
Method, do-sql: Exported generic functions
Method, escape-sql: Exported generic functions
Method, execute: Exported generic functions
Method, execute-using-connection: Exported generic functions
Method, fetch: Exported generic functions
Method, fetch-all: Exported generic functions
Method, fetch-using-connection: Exported generic functions
Method, free-query-resources: Exported generic functions
Method, get-conn: Internal generic functions
Method, get-identifier: Internal generic functions
Method, get-state: Internal generic functions
Method, make-connection: Exported generic functions
Method, ping: Exported generic functions
Method, prepare: Exported generic functions
Method, prepare-sql: Internal generic functions
Method, query-connection: Exported generic functions
Method, query-prepared: Exported generic functions
Method, query-results: Exported generic functions
Method, query-row-count: Exported generic functions
Method, query-sql: Exported generic functions
Method, release-savepoint: Exported generic functions
Method, release-savepoint: Exported generic functions
Method, rollback: Exported generic functions
Method, rollback: Exported generic functions
Method, rollback-savepoint: Exported generic functions
Method, rollback-savepoint: Exported generic functions
Method, row-count: Exported generic functions
Method, savepoint: Exported generic functions

P
ping: Exported generic functions
ping: Exported generic functions
prepare: Exported generic functions
prepare: Exported generic functions
prepare-sql: Internal generic functions
prepare-sql: Internal generic functions

Q
query-connection: Exported generic functions
query-connection: Exported generic functions
query-prepared: Exported generic functions
query-prepared: Exported generic functions
query-results: Exported generic functions
query-results: Exported generic functions
query-row-count: Exported generic functions
query-row-count: Exported generic functions
query-sql: Exported generic functions
query-sql: Exported generic functions

R
release-savepoint: Exported generic functions
release-savepoint: Exported generic functions
release-savepoint: Exported generic functions
rollback: Exported generic functions
rollback: Exported generic functions
rollback: Exported generic functions
rollback-savepoint: Exported generic functions
rollback-savepoint: Exported generic functions
rollback-savepoint: Exported generic functions
row-count: Exported generic functions
row-count: Exported generic functions

S
savepoint: Exported generic functions
savepoint: Exported generic functions
simple-sql-logger: Exported functions
sql-log: Exported functions

W
with-connection: Exported macros
with-retrying: Internal macros
with-savepoint: Exported macros
with-took-ms: Exported macros
with-transaction: Exported macros

Jump to:   %   (  
A   B   C   D   E   F   G   I   L   M   P   Q   R   S   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   %   *  
A   C   D   E   I   M   P   R   S  
Index Entry  Section

%
%handle: Exported classes
%handle: Exported classes

*
*connection-pool-cleanup-lock*: Internal special variables
*sql-execution-hooks*: Exported special variables
*threads-connection-pool*: Internal special variables
*transaction-state*: Internal special variables

A
auto-commit: Exported classes
auto-commit: Exported classes

C
conn: Internal classes
connection: Exported classes
connection: Exported classes

D
database-name: Exported classes
database-name: Exported classes

E
error-code: Exported conditions
error-code: Exported conditions

I
identifier: Internal classes

M
message: Exported conditions
message: Exported conditions
method-name: Exported conditions
method-name: Exported conditions
method-name: Exported conditions
method-name: Exported conditions

P
prepared: Exported classes
prepared: Exported classes

R
results: Exported classes
results: Exported classes
row-count: Exported classes
row-count: Exported classes

S
Slot, %handle: Exported classes
Slot, %handle: Exported classes
Slot, auto-commit: Exported classes
Slot, auto-commit: Exported classes
Slot, conn: Internal classes
Slot, connection: Exported classes
Slot, connection: Exported classes
Slot, database-name: Exported classes
Slot, database-name: Exported classes
Slot, error-code: Exported conditions
Slot, error-code: Exported conditions
Slot, identifier: Internal classes
Slot, message: Exported conditions
Slot, message: Exported conditions
Slot, method-name: Exported conditions
Slot, method-name: Exported conditions
Slot, method-name: Exported conditions
Slot, method-name: Exported conditions
Slot, prepared: Exported classes
Slot, prepared: Exported classes
Slot, results: Exported classes
Slot, results: Exported classes
Slot, row-count: Exported classes
Slot, row-count: Exported classes
Slot, sql: Exported classes
Slot, sql: Exported classes
Slot, state: Internal classes
Special Variable, *connection-pool-cleanup-lock*: Internal special variables
Special Variable, *sql-execution-hooks*: Exported special variables
Special Variable, *threads-connection-pool*: Internal special variables
Special Variable, *transaction-state*: Internal special variables
sql: Exported classes
sql: Exported classes
state: Internal classes

Jump to:   %   *  
A   C   D   E   I   M   P   R   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   <  
C   D   P   S   T  
Index Entry  Section

<
<dbi-already-commited-error>: Exported conditions
<dbi-already-rolled-back-error>: Exported conditions
<dbi-connection>: Exported classes
<dbi-data-error>: Exported conditions
<dbi-database-error>: Exported conditions
<dbi-driver>: Exported classes
<dbi-error>: Exported conditions
<dbi-integrity-error>: Exported conditions
<dbi-interface-error>: Exported conditions
<dbi-internal-error>: Exported conditions
<dbi-notsupported-error>: Exported conditions
<dbi-operational-error>: Exported conditions
<dbi-programming-error>: Exported conditions
<dbi-query>: Exported classes
<dbi-unimplemented-error>: Exported conditions
<dbi-warning>: Exported conditions

C
cl-dbi: The cl-dbi system
Class, <dbi-connection>: Exported classes
Class, <dbi-driver>: Exported classes
Class, <dbi-query>: Exported classes
Class, dbi-connection: Exported classes
Class, dbi-driver: Exported classes
Class, dbi-query: Exported classes
Class, savepoint-state: Internal classes
Class, transaction-state: Internal classes
Condition, <dbi-already-commited-error>: Exported conditions
Condition, <dbi-already-rolled-back-error>: Exported conditions
Condition, <dbi-data-error>: Exported conditions
Condition, <dbi-database-error>: Exported conditions
Condition, <dbi-error>: Exported conditions
Condition, <dbi-integrity-error>: Exported conditions
Condition, <dbi-interface-error>: Exported conditions
Condition, <dbi-internal-error>: Exported conditions
Condition, <dbi-notsupported-error>: Exported conditions
Condition, <dbi-operational-error>: Exported conditions
Condition, <dbi-programming-error>: Exported conditions
Condition, <dbi-unimplemented-error>: Exported conditions
Condition, <dbi-warning>: Exported conditions
Condition, dbi-already-commited-error: Exported conditions
Condition, dbi-already-rolled-back-error: Exported conditions
Condition, dbi-data-error: Exported conditions
Condition, dbi-database-error: Exported conditions
Condition, dbi-error: Exported conditions
Condition, dbi-integrity-error: Exported conditions
Condition, dbi-interface-error: Exported conditions
Condition, dbi-internal-error: Exported conditions
Condition, dbi-notsupported-error: Exported conditions
Condition, dbi-operational-error: Exported conditions
Condition, dbi-programming-error: Exported conditions
Condition, dbi-unimplemented-error: Exported conditions
Condition, dbi-warning: Exported conditions
Condition, transaction-done-condition: Internal conditions

D
dbi: The dbi system
dbi: The dbi package
dbi-already-commited-error: Exported conditions
dbi-already-rolled-back-error: Exported conditions
dbi-connection: Exported classes
dbi-data-error: Exported conditions
dbi-database-error: Exported conditions
dbi-driver: Exported classes
dbi-error: Exported conditions
dbi-integrity-error: Exported conditions
dbi-interface-error: Exported conditions
dbi-internal-error: Exported conditions
dbi-notsupported-error: Exported conditions
dbi-operational-error: Exported conditions
dbi-programming-error: Exported conditions
dbi-query: Exported classes
dbi-unimplemented-error: Exported conditions
dbi-warning: Exported conditions
dbi.driver: The dbi․driver package
dbi.error: The dbi․error package
dbi.logger: The dbi․logger package
dbi.utils: The dbi․utils package

P
Package, dbi: The dbi package
Package, dbi.driver: The dbi․driver package
Package, dbi.error: The dbi․error package
Package, dbi.logger: The dbi․logger package
Package, dbi.utils: The dbi․utils package

S
savepoint-state: Internal classes
System, cl-dbi: The cl-dbi system
System, dbi: The dbi system

T
transaction-done-condition: Internal conditions
transaction-state: Internal classes

Jump to:   <  
C   D   P   S   T