Previous: , Up: CL-DBI   [Contents][Index]


5.16.2.3 API

  1. User-Level API
    • connect [driver-name & params] => <dbi-connection>
    • connect-cached [driver-name & params] => <dbi-connection>
    • disconnect [<dbi-connection>] => T or NIL
    • prepare [conn sql] => <dbi-query>
    • execute [query &optional params] => something
    • fetch [result] => a row data as plist
    • fetch-all [result] => a list of all row data
    • do-sql [conn sql &optional params]
    • list-all-drivers [] => (<dbi-driver> ..)
    • find-driver [driver-name] => <dbi-driver>
    • with-transaction [conn]
    • begin-transaction [conn]
    • commit [conn]
    • rollback [conn]
    • ping [conn] => T or NIL
    • row-count [conn] => a number of rows modified by the last executed INSERT/UPDATE/DELETE
    • with-connection [connection-variable-name &body body]
  2. Driver-Level API
    • <dbi-driver>
    • <dbi-connection>
    • make-connection [driver params]
    • disconnect [<dbi-connection>] => T or NIL
    • prepare [conn sql] => <dbi-query>
    • fetch-using-connection [conn result] => a row data as plist
    • do-sql [conn sql &optional params]
    • execute-using-connection => something
    • escape-sql => string
    • begin-transaction [conn]
    • commit [conn]
    • rollback [conn]
    • ping [conn] => T or NIL
    • row-count [conn] => a number of rows modified by the last executed INSERT/UPDATE/DELETE
    • free-query-resources [query] free resources associated with a prepared query (this is required only for sqlite3 driver at the moment)
  3. 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:

    • SQL (string)
    • placeholder parameters (list)
    • Row count of the results (integer or null)
    • Took time in miliseconds (integer or null)

      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*)
    

Previous: Usage—DBI Connections, Up: CL-DBI   [Contents][Index]