direct-sqlite-2.3.23: Low-level binding to SQLite3. Includes UTF8 and BLOB support.

Safe HaskellNone
LanguageHaskell2010

Database.SQLite3.Bindings

Contents

Synopsis

Documentation

Connection management

c_sqlite3_open :: CString -> Ptr (Ptr CDatabase) -> IO CError Source #

http://www.sqlite.org/c3ref/open.html

This sets the 'Ptr CDatabase' even on failure.

c_sqlite3_trace Source #

Arguments

:: Ptr CDatabase 
-> FunPtr (CTraceCallback a)

Optional callback function called for each row

-> Ptr a

Context passed to the callback

-> IO (Ptr ())

Returns context pointer from previously registered trace

type CTraceCallback a Source #

Arguments

 = Ptr a 
-> CString

UTF-8 rendering of the SQL statement text as the statement first begins executing

-> IO () 

Simple query execution

c_sqlite3_exec Source #

Arguments

:: Ptr CDatabase 
-> CString

SQL statement, UTF-8 encoded

-> FunPtr (CExecCallback a)

Optional callback function called for each row

-> Ptr a

Context passed to the callback

-> Ptr CString

OUT: Error message string

-> IO CError 

type CExecCallback a Source #

Arguments

 = Ptr a 
-> CColumnCount

Number of columns, which is the number of elements in the following arrays.

-> Ptr CString

Array of column values, as returned by c_sqlite3_column_text. Null values are represented as null pointers.

-> Ptr CString

Array of column names

-> IO CInt

If the callback returns non-zero, then c_sqlite3_exec returns SQLITE_ABORT (ErrorAbort).

mkCExecCallback :: CExecCallback a -> IO (FunPtr (CExecCallback a)) Source #

A couple important things to know about callbacks from Haskell code:

  • If the callback throws an exception, apparently, the whole program is terminated.
  • Remember to call freeHaskellFunPtr when you are done with the wrapper, to avoid leaking memory.

Statement management

c_sqlite3_prepare_v2 Source #

Arguments

:: Ptr CDatabase 
-> CString

SQL statement, UTF-8 encoded

-> CNumBytes

Maximum length of the SQL statement, in bytes. If this is negative, then the SQL statement is treated as a NUL-terminated string.

-> Ptr (Ptr CStatement)

OUT: Statement handle. This must not be null.

-> Ptr CString

OUT: Pointer to unused portion of zSql

-> IO CError 

http://www.sqlite.org/c3ref/prepare.html

If the query contains no SQL statements, this returns SQLITE_OK and sets the Ptr CStatement to null.

c_sqlite3_reset :: Ptr CStatement -> IO CError Source #

http://www.sqlite.org/c3ref/reset.html

Warning: If the most recent c_sqlite3_step call failed, this will return the corresponding error code.

c_sqlite3_finalize :: Ptr CStatement -> IO CError Source #

http://www.sqlite.org/c3ref/finalize.html

Warning: If the most recent c_sqlite3_step call failed, this will return the corresponding error code.

c_sqlite3_clear_bindings :: Ptr CStatement -> IO CError Source #

http://www.sqlite.org/c3ref/clear_bindings.html

A look at the source reveals that this function always returns SQLITE_OK.

Parameter and column information

c_sqlite3_bind_parameter_count :: Ptr CStatement -> IO CParamIndex Source #

http://www.sqlite.org/c3ref/bind_parameter_count.html

This returns the index of the largest (rightmost) parameter, which is not necessarily the number of parameters. If numbered parameters like ?5 are used, there may be gaps in the list.

Binding Values To Prepared Statements

c_sqlite3_bind_blob Source #

Arguments

:: Ptr CStatement 
-> CParamIndex

Index of the SQL parameter to be set

-> Ptr a

Value to bind to the parameter.

Warning: If this pointer is NULL, this will bind a null value, rather than an empty blob.

-> CNumBytes

Length, in bytes. This must not be negative.

-> Ptr CDestructor 
-> IO CError 

c_sqlite3_bind_text Source #

Arguments

:: Ptr CStatement 
-> CParamIndex 
-> CString

Warning: If this pointer is NULL, this will bind a null value, rather than an empty text.

-> CNumBytes

Length, in bytes. If this is negative, the value is treated as a NUL-terminated string.

-> Ptr CDestructor 
-> IO CError 

Result Values From A Query

Result statistics

Create Or Redefine SQL Functions

c_sqlite3_create_function_v2 Source #

Arguments

:: Ptr CDatabase 
-> CString

Name of the function

-> CArgCount

Number of arguments

-> CInt

Preferred text encoding (also used to pass flags)

-> Ptr a

User data

-> FunPtr CFunc 
-> FunPtr CFunc 
-> FunPtr CFuncFinal 
-> FunPtr (CFuncDestroy a) 
-> IO CError 

type CFuncDestroy a = Ptr a -> IO () Source #

Obtaining SQL Function Parameter Values

Setting The Result Of An SQL Function

Define New Collating Sequences

Miscellaneous

Extensions

Write-Ahead Log Commit Hook

Incremental blob I/O

c_sqlite3_blob_open Source #

Arguments

:: Ptr CDatabase 
-> CString

Database name

-> CString

Table name

-> CString

Column name

-> Int64

Row ROWID

-> CInt

Flags

-> Ptr (Ptr CBlob)

OUT: Blob handle, will be NULL on error

-> IO CError 

Online Backup API

c_sqlite3_backup_init Source #

Arguments

:: Ptr CDatabase

Destination database handle

-> CString

Destination database name

-> Ptr CDatabase

Source database handle

-> CString

Source database name

-> IO (Ptr CBackup)