{-# LANGUAGE ForeignFunctionInterface #-}moduleDatabase.SQLite3.Bindings(moduleDatabase.SQLite3.Bindings.Types,-- * Connection managementc_sqlite3_open,c_sqlite3_close,c_sqlite3_errmsg,-- * Simple query execution-- | <http://sqlite.org/c3ref/exec.html>c_sqlite3_exec,CExecCallback,mkCExecCallback,-- * Statement managementc_sqlite3_prepare_v2,c_sqlite3_db_handle,c_sqlite3_step,c_sqlite3_reset,c_sqlite3_finalize,c_sqlite3_clear_bindings,-- * Parameter and column informationc_sqlite3_bind_parameter_count,c_sqlite3_bind_parameter_name,c_sqlite3_column_count,-- * Binding Values To Prepared Statements-- | <http://www.sqlite.org/c3ref/bind_blob.html>c_sqlite3_bind_blob,c_sqlite3_bind_text,c_sqlite3_bind_double,c_sqlite3_bind_int64,c_sqlite3_bind_null,-- * Result Values From A Query-- | <http://www.sqlite.org/c3ref/column_blob.html>c_sqlite3_column_type,c_sqlite3_column_bytes,c_sqlite3_column_blob,c_sqlite3_column_int64,c_sqlite3_column_double,c_sqlite3_column_text,-- * Miscellaneousc_sqlite3_free,)whereimportDatabase.SQLite3.Bindings.TypesimportForeignimportForeign.C-- | <http://www.sqlite.org/c3ref/open.html>---- This sets the @'Ptr CDatabase'@ even on failure.foreignimportccall"sqlite3_open"c_sqlite3_open::CString->Ptr(PtrCDatabase)->IOCError-- | <http://www.sqlite.org/c3ref/close.html>foreignimportccall"sqlite3_close"c_sqlite3_close::PtrCDatabase->IOCError-- | <http://www.sqlite.org/c3ref/errcode.html>foreignimportccall"sqlite3_errmsg"c_sqlite3_errmsg::PtrCDatabase->IOCStringforeignimportccall"sqlite3_exec"c_sqlite3_exec::PtrCDatabase->CString-- ^ SQL statement, UTF-8 encoded->FunPtr(CExecCallbacka)-- ^ Optional callback function called for each row->Ptra-- ^ Context passed to the callback->PtrCString-- ^ OUT: Error message string->IOCErrortypeCExecCallbacka=Ptra->ColumnCount-- ^ Number of columns, which is the number of elements in-- the following arrays.->PtrCString-- ^ Array of column names->PtrCString-- ^ Array of column values, as returned by-- 'c_sqlite3_column_text'. Null values are represented-- as null pointers.->CInt-- ^ If the callback returns non-zero, then-- 'c_sqlite3_exec' returns @SQLITE_ABORT@-- ('ErrorAbort').-- | 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.foreignimportccall"wrapper"mkCExecCallback::CExecCallbacka->IO(FunPtr(CExecCallbacka))-- | <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.foreignimportccall"sqlite3_prepare_v2"c_sqlite3_prepare_v2::PtrCDatabase->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(PtrCStatement)-- ^ OUT: Statement handle. This must not be null.->PtrCString-- ^ OUT: Pointer to unused portion of zSql->IOCError-- | <http://www.sqlite.org/c3ref/db_handle.html>foreignimportccall"sqlite3_db_handle"c_sqlite3_db_handle::PtrCStatement->IO(PtrCDatabase)-- | <http://www.sqlite.org/c3ref/step.html>foreignimportccall"sqlite3_step"c_sqlite3_step::PtrCStatement->IOCError-- | <http://www.sqlite.org/c3ref/reset.html>---- /Warning:/ If the most recent 'c_sqlite3_step' call failed,-- this will return the corresponding error code.foreignimportccall"sqlite3_reset"c_sqlite3_reset::PtrCStatement->IOCError-- | <http://www.sqlite.org/c3ref/finalize.html>---- /Warning:/ If the most recent 'c_sqlite3_step' call failed,-- this will return the corresponding error code.foreignimportccall"sqlite3_finalize"c_sqlite3_finalize::PtrCStatement->IOCError-- | <http://www.sqlite.org/c3ref/clear_bindings.html>---- A look at the source reveals that this function always returns @SQLITE_OK@.foreignimportccall"sqlite3_clear_bindings"c_sqlite3_clear_bindings::PtrCStatement->IOCError-- | <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.foreignimportccall"sqlite3_bind_parameter_count"c_sqlite3_bind_parameter_count::PtrCStatement->IOParamIndex-- | <http://www.sqlite.org/c3ref/bind_parameter_name.html>foreignimportccall"sqlite3_bind_parameter_name"c_sqlite3_bind_parameter_name::PtrCStatement->ParamIndex->IOCString-- | <http://www.sqlite.org/c3ref/column_count.html>foreignimportccall"sqlite3_column_count"c_sqlite3_column_count::PtrCStatement->IOColumnCountforeignimportccall"sqlite3_bind_blob"c_sqlite3_bind_blob::PtrCStatement->ParamIndex-- ^ Index of the SQL parameter to be set->Ptra-- ^ 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.->PtrCDestructor->IOCErrorforeignimportccall"sqlite3_bind_text"c_sqlite3_bind_text::PtrCStatement->ParamIndex->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.->PtrCDestructor->IOCErrorforeignimportccall"sqlite3_bind_double"c_sqlite3_bind_double::PtrCStatement->ParamIndex->Double->IOCErrorforeignimportccall"sqlite3_bind_int64"c_sqlite3_bind_int64::PtrCStatement->ParamIndex->Int64->IOCErrorforeignimportccall"sqlite3_bind_null"c_sqlite3_bind_null::PtrCStatement->ParamIndex->IOCErrorforeignimportccall"sqlite3_column_type"c_sqlite3_column_type::PtrCStatement->ColumnIndex->IOCColumnTypeforeignimportccall"sqlite3_column_bytes"c_sqlite3_column_bytes::PtrCStatement->ColumnIndex->IOCNumBytesforeignimportccall"sqlite3_column_blob"c_sqlite3_column_blob::PtrCStatement->ColumnIndex->IO(Ptra)foreignimportccall"sqlite3_column_text"c_sqlite3_column_text::PtrCStatement->ColumnIndex->IOCStringforeignimportccall"sqlite3_column_int64"c_sqlite3_column_int64::PtrCStatement->ColumnIndex->IOInt64foreignimportccall"sqlite3_column_double"c_sqlite3_column_double::PtrCStatement->ColumnIndex->IODouble-- | <http://sqlite.org/c3ref/free.html>foreignimportccall"sqlite3_free"c_sqlite3_free::Ptra->IO()