-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Low-level binding to SQLite3. Includes UTF8 and BLOB support. -- -- This package is not very different from the other SQLite3 bindings out -- there, but it fixes a few deficiencies I was finding. As compared to -- bindings-sqlite3, it is slightly higher-level, in that it supports -- marshalling of data values to and from the database. In particular, it -- supports strings encoded as UTF8, and BLOBs represented as -- ByteStrings. -- -- Release history: -- -- @package direct-sqlite @version 2.3.6 module Database.SQLite3.Bindings.Types -- | http://www.sqlite.org/c3ref/sqlite3.html -- -- CDatabase = sqlite3 data CDatabase -- | http://www.sqlite.org/c3ref/stmt.html -- -- CStatement = sqlite3_stmt data CStatement -- | http://www.sqlite.org/c3ref/c_abort.html newtype CError CError :: CInt -> CError -- | Note that this is a partial function. If the error code is invalid, or -- perhaps introduced in a newer version of SQLite but this library has -- not been updated to support it, the result is undefined. -- -- To be clear, if decodeError fails, it is undefined -- behavior, not an exception you can handle. -- -- Therefore, do not use direct-sqlite with a different version of SQLite -- than the one bundled (currently, 3.7.13). If you do, ensure that -- decodeError and decodeColumnType are still exhaustive. decodeError :: CError -> Error encodeError :: Error -> CError data Error -- | Successful result ErrorOK :: Error -- | SQL error or missing database ErrorError :: Error -- | Internal logic error in SQLite ErrorInternal :: Error -- | Access permission denied ErrorPermission :: Error -- | Callback routine requested an abort ErrorAbort :: Error -- | The database file is locked ErrorBusy :: Error -- | A table in the database is locked ErrorLocked :: Error -- | A malloc() failed ErrorNoMemory :: Error -- | Attempt to write a readonly database ErrorReadOnly :: Error -- | Operation terminated by sqlite3_interrupt() ErrorInterrupt :: Error -- | Some kind of disk I/O error occurred ErrorIO :: Error -- | The database disk image is malformed ErrorCorrupt :: Error -- | Unknown opcode in sqlite3_file_control() ErrorNotFound :: Error -- | Insertion failed because database is full ErrorFull :: Error -- | Unable to open the database file ErrorCan'tOpen :: Error -- | Database lock protocol error ErrorProtocol :: Error -- | Database is empty ErrorEmpty :: Error -- | The database schema changed ErrorSchema :: Error -- | String or BLOB exceeds size limit ErrorTooBig :: Error -- | Abort due to constraint violation ErrorConstraint :: Error -- | Data type mismatch ErrorMismatch :: Error -- | Library used incorrectly ErrorMisuse :: Error -- | Uses OS features not supported on host ErrorNoLargeFileSupport :: Error -- | Authorization denied ErrorAuthorization :: Error -- | Auxiliary database format error ErrorFormat :: Error -- | 2nd parameter to sqlite3_bind out of range ErrorRange :: Error -- | File opened that is not a database file ErrorNotADatabase :: Error -- | sqlite3_step() has another row ready ErrorRow :: Error -- | sqlite3_step() has finished executing ErrorDone :: Error -- | http://www.sqlite.org/c3ref/c_blob.html newtype CColumnType CColumnType :: CInt -> CColumnType -- | Note that this is a partial function. See decodeError for more -- information. decodeColumnType :: CColumnType -> ColumnType encodeColumnType :: ColumnType -> CColumnType data ColumnType IntegerColumn :: ColumnType FloatColumn :: ColumnType TextColumn :: ColumnType BlobColumn :: ColumnType NullColumn :: ColumnType -- | Index of a parameter in a parameterized query. Parameter indices start -- from 1. -- -- When a query is prepared, SQLite allocates an array indexed -- from 1 to the highest parameter index. For example: -- --
--   >Right stmt <- prepare conn "SELECT ?1, ?5, ?3, ?"
--   >bindParameterCount stmt
--   ParamIndex 6
--   
-- -- This will allocate an array indexed from 1 to 6 (? takes the -- highest preceding index plus one). The array is initialized with null -- values. When you bind a parameter with bindSQLData, it assigns -- a new value to one of these indices. -- -- See http://www.sqlite.org/lang_expr.html#varparam for the -- syntax of parameter placeholders, and how parameter indices are -- assigned. newtype ParamIndex ParamIndex :: Int -> ParamIndex -- | Index of a column in a result set. Column indices start from 0. newtype ColumnIndex ColumnIndex :: Int -> ColumnIndex -- | Number of columns in a result set. type ColumnCount = ColumnIndex newtype CParamIndex CParamIndex :: CInt -> CParamIndex newtype CColumnIndex CColumnIndex :: CInt -> CColumnIndex type CColumnCount = CColumnIndex newtype CNumBytes CNumBytes :: CInt -> CNumBytes -- | http://www.sqlite.org/c3ref/c_static.html -- -- Ptr CDestructor = sqlite3_destructor_type data CDestructor -- | Tells SQLite3 to make its own private copy of the data c_SQLITE_TRANSIENT :: Ptr CDestructor -- | The Database.SQLite3 and Database.SQLite3.Direct modules -- use higher-level representations of some types than those used in the -- FFI signatures (Database.SQLite3.Bindings). This typeclass -- helps with the conversions. class FFIType public ffi | public -> ffi, ffi -> public toFFI :: FFIType public ffi => public -> ffi fromFFI :: FFIType public ffi => ffi -> public instance Eq Error instance Show Error instance Eq ColumnType instance Show ColumnType instance Eq ParamIndex instance Ord ParamIndex instance Enum ParamIndex instance Num ParamIndex instance Real ParamIndex instance Integral ParamIndex instance Eq ColumnIndex instance Ord ColumnIndex instance Enum ColumnIndex instance Num ColumnIndex instance Real ColumnIndex instance Integral ColumnIndex instance Eq CParamIndex instance Ord CParamIndex instance Enum CParamIndex instance Num CParamIndex instance Real CParamIndex instance Integral CParamIndex instance Eq CColumnIndex instance Ord CColumnIndex instance Enum CColumnIndex instance Num CColumnIndex instance Real CColumnIndex instance Integral CColumnIndex instance Eq CNumBytes instance Ord CNumBytes instance Show CNumBytes instance Enum CNumBytes instance Num CNumBytes instance Real CNumBytes instance Integral CNumBytes instance Eq CError instance Show CError instance Eq CColumnType instance Show CColumnType instance FFIType ColumnType CColumnType instance FFIType Error CError instance FFIType ColumnIndex CColumnIndex instance FFIType ParamIndex CParamIndex instance Show CColumnIndex instance Show CParamIndex instance Show ColumnIndex instance Show ParamIndex module Database.SQLite3.Bindings -- | http://www.sqlite.org/c3ref/open.html -- -- This sets the 'Ptr CDatabase' even on failure. c_sqlite3_open :: CString -> Ptr (Ptr CDatabase) -> IO CError -- | http://www.sqlite.org/c3ref/close.html c_sqlite3_close :: Ptr CDatabase -> IO CError -- | http://www.sqlite.org/c3ref/errcode.html c_sqlite3_errmsg :: Ptr CDatabase -> IO CString -- | http://www.sqlite.org/c3ref/interrupt.html c_sqlite3_interrupt :: Ptr CDatabase -> IO () -- | http://www.sqlite.org/c3ref/profile.html c_sqlite3_trace :: Ptr CDatabase -> FunPtr (CTraceCallback a) -> Ptr a -> IO (Ptr ()) type CTraceCallback a = Ptr a -> CString -> IO () mkCTraceCallback :: CTraceCallback a -> IO (FunPtr (CTraceCallback a)) -- | http://www.sqlite.org/c3ref/get_autocommit.html c_sqlite3_get_autocommit :: Ptr CDatabase -> IO CInt c_sqlite3_exec :: Ptr CDatabase -> CString -> FunPtr (CExecCallback a) -> Ptr a -> Ptr CString -> IO CError type CExecCallback a = Ptr a -> CColumnCount -> Ptr CString -> Ptr CString -> IO CInt -- | A couple important things to know about callbacks from Haskell code: -- -- mkCExecCallback :: CExecCallback a -> IO (FunPtr (CExecCallback a)) -- | 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_prepare_v2 :: Ptr CDatabase -> CString -> CNumBytes -> Ptr (Ptr CStatement) -> Ptr CString -> IO CError -- | http://www.sqlite.org/c3ref/db_handle.html c_sqlite3_db_handle :: Ptr CStatement -> IO (Ptr CDatabase) -- | http://www.sqlite.org/c3ref/step.html c_sqlite3_step :: Ptr CStatement -> IO CError -- | 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_reset :: Ptr CStatement -> IO CError -- | 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_finalize :: Ptr CStatement -> IO CError -- | http://www.sqlite.org/c3ref/clear_bindings.html -- -- A look at the source reveals that this function always returns -- SQLITE_OK. c_sqlite3_clear_bindings :: Ptr CStatement -> IO CError -- | http://www.sqlite.org/c3ref/sql.html c_sqlite3_sql :: Ptr CStatement -> IO CString -- | 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. c_sqlite3_bind_parameter_count :: Ptr CStatement -> IO CParamIndex -- | http://www.sqlite.org/c3ref/bind_parameter_name.html c_sqlite3_bind_parameter_name :: Ptr CStatement -> CParamIndex -> IO CString -- | http://www.sqlite.org/c3ref/column_count.html c_sqlite3_column_count :: Ptr CStatement -> IO CColumnCount -- | http://www.sqlite.org/c3ref/column_name.html c_sqlite3_column_name :: Ptr CStatement -> CColumnIndex -> IO CString c_sqlite3_bind_blob :: Ptr CStatement -> CParamIndex -> Ptr a -> CNumBytes -> Ptr CDestructor -> IO CError c_sqlite3_bind_text :: Ptr CStatement -> CParamIndex -> CString -> CNumBytes -> Ptr CDestructor -> IO CError c_sqlite3_bind_double :: Ptr CStatement -> CParamIndex -> Double -> IO CError c_sqlite3_bind_int64 :: Ptr CStatement -> CParamIndex -> Int64 -> IO CError c_sqlite3_bind_null :: Ptr CStatement -> CParamIndex -> IO CError c_sqlite3_column_type :: Ptr CStatement -> CColumnIndex -> IO CColumnType c_sqlite3_column_bytes :: Ptr CStatement -> CColumnIndex -> IO CNumBytes c_sqlite3_column_blob :: Ptr CStatement -> CColumnIndex -> IO (Ptr a) c_sqlite3_column_int64 :: Ptr CStatement -> CColumnIndex -> IO Int64 c_sqlite3_column_double :: Ptr CStatement -> CColumnIndex -> IO Double c_sqlite3_column_text :: Ptr CStatement -> CColumnIndex -> IO CString -- | http://www.sqlite.org/c3ref/last_insert_rowid.html c_sqlite3_last_insert_rowid :: Ptr CDatabase -> IO Int64 -- | http://www.sqlite.org/c3ref/changes.html c_sqlite3_changes :: Ptr CDatabase -> IO CInt -- | http://www.sqlite.org/c3ref/total_changes.html c_sqlite3_total_changes :: Ptr CDatabase -> IO CInt -- | http://sqlite.org/c3ref/free.html c_sqlite3_free :: Ptr a -> IO () -- | This API is a slightly lower-level version of Database.SQLite3. -- Namely: -- -- module Database.SQLite3.Direct -- | http://www.sqlite.org/c3ref/open.html open :: Utf8 -> IO (Either (Error, Utf8) Database) -- | http://www.sqlite.org/c3ref/close.html close :: Database -> IO (Either Error ()) -- | http://www.sqlite.org/c3ref/errcode.html errmsg :: Database -> IO Utf8 -- | http://www.sqlite.org/c3ref/profile.html -- -- Enable/disable tracing of SQL execution. Tracing can be disabled by -- setting Nothing as the logger callback. -- -- Warning: If the logger callback throws an exception, your whole -- program will crash. Enable only for debugging! setTrace :: Database -> Maybe (Utf8 -> IO ()) -> IO () -- | http://www.sqlite.org/c3ref/get_autocommit.html -- -- Return True if the connection is in autocommit mode, or -- False if a transaction started with BEGIN is still -- active. -- -- Be warned that some errors roll back the transaction automatically, -- and that ROLLBACK will throw an error if no transaction is -- active. Use getAutoCommit to avoid such an error: -- --
--   autocommit <- getAutoCommit conn
--   when (not autocommit) $
--       exec conn "ROLLBACK"
--   
getAutoCommit :: Database -> IO Bool exec :: Database -> Utf8 -> IO (Either (Error, Utf8) ()) -- | Like exec, but invoke the callback for each result row. -- -- If the callback throws an exception, it will be rethrown by -- execWithCallback. execWithCallback :: Database -> Utf8 -> ExecCallback -> IO (Either (Error, Utf8) ()) type ExecCallback = ColumnCount -> [Utf8] -> [Maybe Utf8] -> IO () -- | http://www.sqlite.org/c3ref/prepare.html -- -- If the query contains no SQL statements, this returns Right -- Nothing. prepare :: Database -> Utf8 -> IO (Either Error (Maybe Statement)) -- | http://www.sqlite.org/c3ref/db_handle.html getStatementDatabase :: Statement -> IO Database -- | http://www.sqlite.org/c3ref/step.html step :: Statement -> IO (Either Error StepResult) -- | http://www.sqlite.org/c3ref/reset.html -- -- Warning: -- -- reset :: Statement -> IO (Either Error ()) -- | http://www.sqlite.org/c3ref/finalize.html -- -- Warning: If the most recent step call failed, this will -- return the corresponding error. finalize :: Statement -> IO (Either Error ()) -- | http://www.sqlite.org/c3ref/clear_bindings.html -- -- Set all parameters in the prepared statement to null. clearBindings :: Statement -> IO () -- | http://www.sqlite.org/c3ref/sql.html -- -- Return a copy of the original SQL text used to compile the statement. statementSql :: Statement -> IO (Maybe Utf8) -- | http://www.sqlite.org/c3ref/bind_parameter_count.html -- -- This returns the index of the largest (rightmost) parameter. Note that -- this is not necessarily the number of parameters. If numbered -- parameters like ?5 are used, there may be gaps in the list. -- -- See ParamIndex for more information. bindParameterCount :: Statement -> IO ParamIndex -- | http://www.sqlite.org/c3ref/bind_parameter_name.html bindParameterName :: Statement -> ParamIndex -> IO (Maybe Utf8) -- | http://www.sqlite.org/c3ref/column_count.html columnCount :: Statement -> IO ColumnCount -- | http://www.sqlite.org/c3ref/column_name.html columnName :: Statement -> ColumnIndex -> IO (Maybe Utf8) bindInt64 :: Statement -> ParamIndex -> Int64 -> IO (Either Error ()) bindDouble :: Statement -> ParamIndex -> Double -> IO (Either Error ()) bindText :: Statement -> ParamIndex -> Utf8 -> IO (Either Error ()) bindBlob :: Statement -> ParamIndex -> ByteString -> IO (Either Error ()) bindNull :: Statement -> ParamIndex -> IO (Either Error ()) columnType :: Statement -> ColumnIndex -> IO ColumnType columnInt64 :: Statement -> ColumnIndex -> IO Int64 columnDouble :: Statement -> ColumnIndex -> IO Double columnText :: Statement -> ColumnIndex -> IO Utf8 columnBlob :: Statement -> ColumnIndex -> IO ByteString -- | http://www.sqlite.org/c3ref/last_insert_rowid.html lastInsertRowId :: Database -> IO Int64 -- | http://www.sqlite.org/c3ref/changes.html -- -- Return the number of rows that were changed, inserted, or deleted by -- the most recent INSERT, DELETE, or UPDATE -- statement. changes :: Database -> IO Int -- | http://www.sqlite.org/c3ref/total_changes.html -- -- Return the total number of row changes caused by INSERT, -- DELETE, or UPDATE statements since the -- Database was opened. totalChanges :: Database -> IO Int -- | http://www.sqlite.org/c3ref/interrupt.html -- -- Cause any pending operation on the Database handle to stop at -- its earliest opportunity. This simply sets a flag and returns -- immediately. It does not wait for the pending operation to finish. -- -- You'll need to compile with -threaded for this to do any -- good. Without -threaded, FFI calls block the whole RTS, -- meaning interrupt would never run at the same time as -- step. interrupt :: Database -> IO () newtype Database Database :: (Ptr CDatabase) -> Database newtype Statement Statement :: (Ptr CStatement) -> Statement data ColumnType IntegerColumn :: ColumnType FloatColumn :: ColumnType TextColumn :: ColumnType BlobColumn :: ColumnType NullColumn :: ColumnType data StepResult Row :: StepResult Done :: StepResult data Error -- | Successful result ErrorOK :: Error -- | SQL error or missing database ErrorError :: Error -- | Internal logic error in SQLite ErrorInternal :: Error -- | Access permission denied ErrorPermission :: Error -- | Callback routine requested an abort ErrorAbort :: Error -- | The database file is locked ErrorBusy :: Error -- | A table in the database is locked ErrorLocked :: Error -- | A malloc() failed ErrorNoMemory :: Error -- | Attempt to write a readonly database ErrorReadOnly :: Error -- | Operation terminated by sqlite3_interrupt() ErrorInterrupt :: Error -- | Some kind of disk I/O error occurred ErrorIO :: Error -- | The database disk image is malformed ErrorCorrupt :: Error -- | Unknown opcode in sqlite3_file_control() ErrorNotFound :: Error -- | Insertion failed because database is full ErrorFull :: Error -- | Unable to open the database file ErrorCan'tOpen :: Error -- | Database lock protocol error ErrorProtocol :: Error -- | Database is empty ErrorEmpty :: Error -- | The database schema changed ErrorSchema :: Error -- | String or BLOB exceeds size limit ErrorTooBig :: Error -- | Abort due to constraint violation ErrorConstraint :: Error -- | Data type mismatch ErrorMismatch :: Error -- | Library used incorrectly ErrorMisuse :: Error -- | Uses OS features not supported on host ErrorNoLargeFileSupport :: Error -- | Authorization denied ErrorAuthorization :: Error -- | Auxiliary database format error ErrorFormat :: Error -- | 2nd parameter to sqlite3_bind out of range ErrorRange :: Error -- | File opened that is not a database file ErrorNotADatabase :: Error -- | sqlite3_step() has another row ready ErrorRow :: Error -- | sqlite3_step() has finished executing ErrorDone :: Error -- | A ByteString containing UTF8-encoded text with no NUL -- characters. newtype Utf8 Utf8 :: ByteString -> Utf8 -- | Index of a parameter in a parameterized query. Parameter indices start -- from 1. -- -- When a query is prepared, SQLite allocates an array indexed -- from 1 to the highest parameter index. For example: -- --
--   >Right stmt <- prepare conn "SELECT ?1, ?5, ?3, ?"
--   >bindParameterCount stmt
--   ParamIndex 6
--   
-- -- This will allocate an array indexed from 1 to 6 (? takes the -- highest preceding index plus one). The array is initialized with null -- values. When you bind a parameter with bindSQLData, it assigns -- a new value to one of these indices. -- -- See http://www.sqlite.org/lang_expr.html#varparam for the -- syntax of parameter placeholders, and how parameter indices are -- assigned. newtype ParamIndex ParamIndex :: Int -> ParamIndex -- | Index of a column in a result set. Column indices start from 0. newtype ColumnIndex ColumnIndex :: Int -> ColumnIndex -- | Number of columns in a result set. type ColumnCount = ColumnIndex instance Eq Database instance Show Database instance Eq Statement instance Show Statement instance Eq StepResult instance Show StepResult instance Eq Utf8 instance Ord Utf8 instance Monoid Utf8 instance IsString Utf8 instance Show Utf8 module Database.SQLite3 -- | http://www.sqlite.org/c3ref/open.html open :: Text -> IO Database -- | http://www.sqlite.org/c3ref/close.html close :: Database -> IO () -- | Execute zero or more SQL statements delimited by semicolons. exec :: Database -> Text -> IO () -- | Like exec, but print result rows to stdout. -- -- This is mainly for convenience when experimenting in GHCi. The output -- format may change in the future. execPrint :: Database -> Text -> IO () -- | Like exec, but invoke the callback for each result row. execWithCallback :: Database -> Text -> ExecCallback -> IO () type ExecCallback = ColumnCount -> [Text] -> [Maybe Text] -> IO () -- | http://www.sqlite.org/c3ref/prepare.html -- -- Unlike exec, prepare only executes the first statement, -- and ignores subsequent statements. -- -- If the query string contains no SQL statements, this fails. prepare :: Database -> Text -> IO Statement -- | http://www.sqlite.org/c3ref/prepare.html -- -- It can help to avoid redundant Utf8 to Text conversion if you already -- have Utf8 -- -- If the query string contains no SQL statements, this fails. prepareUtf8 :: Database -> Utf8 -> IO Statement -- | http://www.sqlite.org/c3ref/step.html step :: Statement -> IO StepResult -- | http://www.sqlite.org/c3ref/reset.html -- -- Note that in the C API, sqlite3_reset returns an error code -- if the most recent sqlite3_step indicated an error. We do not -- replicate that behavior here. reset never throws an exception. reset :: Statement -> IO () -- | http://www.sqlite.org/c3ref/finalize.html -- -- Like reset, finalize never throws an exception. finalize :: Statement -> IO () -- | http://www.sqlite.org/c3ref/clear_bindings.html -- -- Set all parameters in the prepared statement to null. clearBindings :: Statement -> IO () -- | http://www.sqlite.org/c3ref/bind_parameter_count.html -- -- This returns the index of the largest (rightmost) parameter. Note that -- this is not necessarily the number of parameters. If numbered -- parameters like ?5 are used, there may be gaps in the list. -- -- See ParamIndex for more information. bindParameterCount :: Statement -> IO ParamIndex -- | http://www.sqlite.org/c3ref/bind_parameter_name.html -- -- Return the N-th SQL parameter name. -- -- Named parameters are returned as-is. E.g. ":v" is returned as Just -- ":v". Unnamed parameters, however, are converted to -- Nothing. -- -- Note that the parameter index starts at 1, not 0. bindParameterName :: Statement -> ParamIndex -> IO (Maybe Text) -- | http://www.sqlite.org/c3ref/column_count.html columnCount :: Statement -> IO ColumnCount -- | http://www.sqlite.org/c3ref/column_name.html -- -- Return the name of a result column. If the column index is out of -- range, return Nothing. columnName :: Statement -> ColumnIndex -> IO (Maybe Text) -- | If the index is not between 1 and bindParameterCount inclusive, -- this fails with ErrorRange. Otherwise, it succeeds, even if the -- query skips this index by using numbered parameters. -- -- Example: -- --
--   > stmt <- prepare conn "SELECT ?1, ?3, ?5"
--   > bindSQLData stmt 1 (SQLInteger 1)
--   > bindSQLData stmt 2 (SQLInteger 2)
--   > bindSQLData stmt 6 (SQLInteger 6)
--   *** Exception: SQLite3 returned ErrorRange while attempting to perform bind int64.
--   > step stmt >> columns stmt
--   [SQLInteger 1,SQLNull,SQLNull]
--   
bindSQLData :: Statement -> ParamIndex -> SQLData -> IO () -- | Convenience function for binding values to all parameters. This will -- fail if the list has the wrong number of parameters. bind :: Statement -> [SQLData] -> IO () bindInt :: Statement -> ParamIndex -> Int -> IO () bindInt64 :: Statement -> ParamIndex -> Int64 -> IO () bindDouble :: Statement -> ParamIndex -> Double -> IO () bindText :: Statement -> ParamIndex -> Text -> IO () bindBlob :: Statement -> ParamIndex -> ByteString -> IO () bindNull :: Statement -> ParamIndex -> IO () column :: Statement -> ColumnIndex -> IO SQLData columns :: Statement -> IO [SQLData] -- | This avoids extra API calls using the list of column types. If passed -- types do not correspond to the actual types, the values will be -- converted according to the rules at -- http://www.sqlite.org/c3ref/column_blob.html. If the list -- contains more items that number of columns, the result is undefined. typedColumns :: Statement -> [Maybe ColumnType] -> IO [SQLData] columnType :: Statement -> ColumnIndex -> IO ColumnType columnInt64 :: Statement -> ColumnIndex -> IO Int64 columnDouble :: Statement -> ColumnIndex -> IO Double -- | This will throw a DecodeError if the datum contains invalid -- UTF-8. If this behavior is undesirable, you can use columnText -- from Database.SQLite3.Direct, which does not perform conversion -- to Text. columnText :: Statement -> ColumnIndex -> IO Text columnBlob :: Statement -> ColumnIndex -> IO ByteString -- | http://www.sqlite.org/c3ref/last_insert_rowid.html lastInsertRowId :: Database -> IO Int64 -- | http://www.sqlite.org/c3ref/changes.html -- -- Return the number of rows that were changed, inserted, or deleted by -- the most recent INSERT, DELETE, or UPDATE -- statement. changes :: Database -> IO Int -- | http://www.sqlite.org/c3ref/interrupt.html -- -- Cause any pending operation on the Database handle to stop at -- its earliest opportunity. This simply sets a flag and returns -- immediately. It does not wait for the pending operation to finish. -- -- You'll need to compile with -threaded for this to do any -- good. Without -threaded, FFI calls block the whole RTS, -- meaning interrupt would never run at the same time as -- step. interrupt :: Database -> IO () -- | Make it possible to interrupt the given database operation with an -- asynchronous exception. This only works if the program is compiled -- with base >= 4.3 and -threaded. -- -- It works by running the callback in a forked thread. If interrupted, -- it uses interrupt to try to stop the operation. interruptibly :: Database -> IO a -> IO a data Database data Statement data SQLData SQLInteger :: !Int64 -> SQLData SQLFloat :: !Double -> SQLData SQLText :: !Text -> SQLData SQLBlob :: !ByteString -> SQLData SQLNull :: SQLData -- | Exception thrown when SQLite3 reports an error. -- -- direct-sqlite may throw other types of exceptions if you misuse the -- API. data SQLError SQLError :: !Error -> Text -> Text -> SQLError -- | Error code returned by API call sqlError :: SQLError -> !Error -- | Text describing the error sqlErrorDetails :: SQLError -> Text -- | Indicates what action produced this error, e.g. exec "SELECT * -- FROM foo" sqlErrorContext :: SQLError -> Text data ColumnType IntegerColumn :: ColumnType FloatColumn :: ColumnType TextColumn :: ColumnType BlobColumn :: ColumnType NullColumn :: ColumnType data StepResult Row :: StepResult Done :: StepResult data Error -- | Successful result ErrorOK :: Error -- | SQL error or missing database ErrorError :: Error -- | Internal logic error in SQLite ErrorInternal :: Error -- | Access permission denied ErrorPermission :: Error -- | Callback routine requested an abort ErrorAbort :: Error -- | The database file is locked ErrorBusy :: Error -- | A table in the database is locked ErrorLocked :: Error -- | A malloc() failed ErrorNoMemory :: Error -- | Attempt to write a readonly database ErrorReadOnly :: Error -- | Operation terminated by sqlite3_interrupt() ErrorInterrupt :: Error -- | Some kind of disk I/O error occurred ErrorIO :: Error -- | The database disk image is malformed ErrorCorrupt :: Error -- | Unknown opcode in sqlite3_file_control() ErrorNotFound :: Error -- | Insertion failed because database is full ErrorFull :: Error -- | Unable to open the database file ErrorCan'tOpen :: Error -- | Database lock protocol error ErrorProtocol :: Error -- | Database is empty ErrorEmpty :: Error -- | The database schema changed ErrorSchema :: Error -- | String or BLOB exceeds size limit ErrorTooBig :: Error -- | Abort due to constraint violation ErrorConstraint :: Error -- | Data type mismatch ErrorMismatch :: Error -- | Library used incorrectly ErrorMisuse :: Error -- | Uses OS features not supported on host ErrorNoLargeFileSupport :: Error -- | Authorization denied ErrorAuthorization :: Error -- | Auxiliary database format error ErrorFormat :: Error -- | 2nd parameter to sqlite3_bind out of range ErrorRange :: Error -- | File opened that is not a database file ErrorNotADatabase :: Error -- | sqlite3_step() has another row ready ErrorRow :: Error -- | sqlite3_step() has finished executing ErrorDone :: Error -- | Index of a parameter in a parameterized query. Parameter indices start -- from 1. -- -- When a query is prepared, SQLite allocates an array indexed -- from 1 to the highest parameter index. For example: -- --
--   >Right stmt <- prepare conn "SELECT ?1, ?5, ?3, ?"
--   >bindParameterCount stmt
--   ParamIndex 6
--   
-- -- This will allocate an array indexed from 1 to 6 (? takes the -- highest preceding index plus one). The array is initialized with null -- values. When you bind a parameter with bindSQLData, it assigns -- a new value to one of these indices. -- -- See http://www.sqlite.org/lang_expr.html#varparam for the -- syntax of parameter placeholders, and how parameter indices are -- assigned. newtype ParamIndex ParamIndex :: Int -> ParamIndex -- | Index of a column in a result set. Column indices start from 0. newtype ColumnIndex ColumnIndex :: Int -> ColumnIndex -- | Number of columns in a result set. type ColumnCount = ColumnIndex instance Typeable SQLData instance Typeable SQLError instance Eq SQLData instance Show SQLData instance Exception SQLError instance Show SQLError