Up: cl-sqlite   [Contents][Index]


5.16.3.1 cl-sqlite Usage

  1. Connect
    connect

    connects to the database

    disconnect

    disconnects from the database

    with-open-database

    macro that opens the database and ensures that it is properly closed after the code is run

  2. Queries
    execute-non-query
    execute-single
    execute-one-row-m-v
    execute-to-list
    execute-to-list/named

    macro is used to execute code within transaction.

    Support for ITERATE is provided

    This clause will bind vars (a list of variables) to the values of the columns of query.

    (for (vars) in-sqlite-query sql on-database db &optional with-parameters (&rest parameters))
    

    Positional and named parameters in queries are supported. Positional parameters are denoted by question mark in SQL code, and named parameters are denoted by prefixing color (:), at sign (@) or dollar sign ($) before parameter name.

  3. Prepared Statement API

    Additionally, it is possible to use the prepared statements API of sqlite. Create the prepared statement with prepare-statement, bind its parameters with bind-parameter, step through it with step-statement, retrieve the results with statement-column-value, and finally reset it to be used again with reset-statement or dispose of it with finalize-statement.

  4. Supported Types

    Following types are supported:

    • Integer. Integers are stored as 64-bit integers.
    • Float. Stored as double. Single-float, double-float and rational may be passed as a parameter, and double-float will be returned.
    • String. Stored as an UTF-8 string.
    • Vector of bytes. Stored as a blob.
    • Null. Passed as NIL to and from database.