-- 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. @package direct-sqlite @version 2.3.26 module Database.SQLite3.Bindings.Types -- | https://www.sqlite.org/c3ref/sqlite3.html -- -- CDatabase = sqlite3 data CDatabase -- | https://www.sqlite.org/c3ref/stmt.html -- -- CStatement = sqlite3_stmt data CStatement -- | https://www.sqlite.org/c3ref/value.html -- -- CValue = sqlite3_value data CValue -- | https://www.sqlite.org/c3ref/context.html -- -- CContext = sqlite3_context data CContext -- | https://www.sqlite.org/c3ref/blob.html -- -- CBlob = sqlite3_blob data CBlob -- | https://www.sqlite.org/c3ref/backup.html -- -- CBackup = sqlite3_backup data CBackup -- | https://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.24.0). If you do, ensure that -- decodeError and decodeColumnType are still exhaustive. decodeError :: CError -> Error encodeError :: Error -> CError -- | https://www.sqlite.org/c3ref/c_abort.html 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 -- | Notifications from sqlite3_log() ErrorNotice :: Error -- | Warnings from sqlite3_log() ErrorWarning :: Error -- | sqlite3_step() has another row ready ErrorRow :: Error -- | sqlite3_step() has finished executing ErrorDone :: Error -- | https://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 -- | https://www.sqlite.org/c3ref/c_blob.html 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 https://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 -- | https://www.sqlite.org/c3ref/c_static.html -- -- Ptr CDestructor = sqlite3_destructor_type data CDestructor -- | Tells SQLite3 that the content pointer is constant and will never -- change c_SQLITE_STATIC :: Ptr CDestructor -- | Tells SQLite3 to make its own private copy of the data c_SQLITE_TRANSIENT :: Ptr CDestructor c_SQLITE_UTF8 :: CInt -- | Number of arguments of a user defined SQL function. newtype ArgCount ArgCount :: Int -> ArgCount -- | Index of an argument to a custom function. Indices start from 0. type ArgIndex = ArgCount newtype CArgCount CArgCount :: CInt -> CArgCount -- | Tells SQLite3 that the defined custom SQL function is deterministic. c_SQLITE_DETERMINISTIC :: CInt -- | 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 GHC.Show.Show Database.SQLite3.Bindings.Types.CColumnType instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.CColumnType instance GHC.Show.Show Database.SQLite3.Bindings.Types.CError instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.CError instance GHC.Real.Integral Database.SQLite3.Bindings.Types.CArgCount instance GHC.Real.Real Database.SQLite3.Bindings.Types.CArgCount instance GHC.Num.Num Database.SQLite3.Bindings.Types.CArgCount instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.CArgCount instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.CArgCount instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.CArgCount instance GHC.Real.Integral Database.SQLite3.Bindings.Types.ArgCount instance GHC.Real.Real Database.SQLite3.Bindings.Types.ArgCount instance GHC.Num.Num Database.SQLite3.Bindings.Types.ArgCount instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.ArgCount instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.ArgCount instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.ArgCount instance GHC.Real.Integral Database.SQLite3.Bindings.Types.CNumBytes instance GHC.Real.Real Database.SQLite3.Bindings.Types.CNumBytes instance GHC.Num.Num Database.SQLite3.Bindings.Types.CNumBytes instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.CNumBytes instance GHC.Show.Show Database.SQLite3.Bindings.Types.CNumBytes instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.CNumBytes instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.CNumBytes instance GHC.Real.Integral Database.SQLite3.Bindings.Types.CColumnIndex instance GHC.Real.Real Database.SQLite3.Bindings.Types.CColumnIndex instance GHC.Num.Num Database.SQLite3.Bindings.Types.CColumnIndex instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.CColumnIndex instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.CColumnIndex instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.CColumnIndex instance GHC.Real.Integral Database.SQLite3.Bindings.Types.CParamIndex instance GHC.Real.Real Database.SQLite3.Bindings.Types.CParamIndex instance GHC.Num.Num Database.SQLite3.Bindings.Types.CParamIndex instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.CParamIndex instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.CParamIndex instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.CParamIndex instance GHC.Real.Integral Database.SQLite3.Bindings.Types.ColumnIndex instance GHC.Real.Real Database.SQLite3.Bindings.Types.ColumnIndex instance GHC.Num.Num Database.SQLite3.Bindings.Types.ColumnIndex instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.ColumnIndex instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.ColumnIndex instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.ColumnIndex instance GHC.Real.Integral Database.SQLite3.Bindings.Types.ParamIndex instance GHC.Real.Real Database.SQLite3.Bindings.Types.ParamIndex instance GHC.Num.Num Database.SQLite3.Bindings.Types.ParamIndex instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.ParamIndex instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.ParamIndex instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.ParamIndex instance GHC.Show.Show Database.SQLite3.Bindings.Types.ColumnType instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.ColumnType instance GHC.Show.Show Database.SQLite3.Bindings.Types.Error instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.Error instance Database.SQLite3.Bindings.Types.FFIType Database.SQLite3.Bindings.Types.ParamIndex Database.SQLite3.Bindings.Types.CParamIndex instance Database.SQLite3.Bindings.Types.FFIType Database.SQLite3.Bindings.Types.ColumnIndex Database.SQLite3.Bindings.Types.CColumnIndex instance Database.SQLite3.Bindings.Types.FFIType Database.SQLite3.Bindings.Types.Error Database.SQLite3.Bindings.Types.CError instance Database.SQLite3.Bindings.Types.FFIType Database.SQLite3.Bindings.Types.ColumnType Database.SQLite3.Bindings.Types.CColumnType instance Database.SQLite3.Bindings.Types.FFIType Database.SQLite3.Bindings.Types.ArgCount Database.SQLite3.Bindings.Types.CArgCount instance GHC.Show.Show Database.SQLite3.Bindings.Types.CArgCount instance GHC.Enum.Bounded Database.SQLite3.Bindings.Types.CArgCount instance GHC.Show.Show Database.SQLite3.Bindings.Types.ArgCount instance GHC.Enum.Bounded Database.SQLite3.Bindings.Types.ArgCount instance GHC.Show.Show Database.SQLite3.Bindings.Types.CColumnIndex instance GHC.Show.Show Database.SQLite3.Bindings.Types.CParamIndex instance GHC.Show.Show Database.SQLite3.Bindings.Types.ColumnIndex instance GHC.Enum.Bounded Database.SQLite3.Bindings.Types.ColumnIndex instance GHC.Show.Show Database.SQLite3.Bindings.Types.ParamIndex instance GHC.Enum.Bounded Database.SQLite3.Bindings.Types.ParamIndex module Database.SQLite3.Bindings -- | https://www.sqlite.org/c3ref/open.html -- -- This sets the 'Ptr CDatabase' even on failure. c_sqlite3_open :: CString -> Ptr (Ptr CDatabase) -> IO CError -- | https://www.sqlite.org/c3ref/close.html c_sqlite3_close :: Ptr CDatabase -> IO CError -- | https://www.sqlite.org/c3ref/errcode.html c_sqlite3_errcode :: Ptr CDatabase -> IO CError -- | https://www.sqlite.org/c3ref/errcode.html c_sqlite3_errmsg :: Ptr CDatabase -> IO CString -- | https://www.sqlite.org/c3ref/interrupt.html c_sqlite3_interrupt :: Ptr CDatabase -> IO () -- | https://www.sqlite.org/c3ref/profile.html c_sqlite3_trace :: Ptr CDatabase -> FunPtr (CTraceCallback a) -> Ptr a -> IO (Ptr ()) type CTraceCallback a = Ptr a -> CString " UTF-8 rendering of the SQL statement text as the statement first begins executing." -> IO () mkCTraceCallback :: CTraceCallback a -> IO (FunPtr (CTraceCallback a)) -- | https://www.sqlite.org/c3ref/get_autocommit.html c_sqlite3_get_autocommit :: Ptr CDatabase -> IO CInt -- | https://www.sqlite.org/c3ref/enable_shared_cache.html c_sqlite3_enable_shared_cache :: Bool -> IO CError -- | https://www.sqlite.org/c3ref/exec.html c_sqlite3_exec :: Ptr CDatabase -> CString -> FunPtr (CExecCallback a) -> Ptr a -> Ptr CString -> IO CError type CExecCallback a = 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')." -- | A couple important things to know about callbacks from Haskell code: -- --
-- autocommit <- getAutoCommit conn -- when (not autocommit) $ -- exec conn "ROLLBACK" --getAutoCommit :: Database -> IO Bool -- | https://www.sqlite.org/c3ref/enable_shared_cache.html -- -- Enable or disable shared cache for all future connections. setSharedCacheEnabled :: Bool -> IO (Either Error ()) -- | https://www.sqlite.org/c3ref/exec.html 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 " Number of columns, which is the number of items in the following lists. This will be the same for every row." -> [Utf8] " List of column names. This will be the same for every row." -> [Maybe Utf8] " List of column values, as returned by 'columnText'." -> IO () -- | https://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)) -- | https://www.sqlite.org/c3ref/db_handle.html getStatementDatabase :: Statement -> IO Database -- | https://www.sqlite.org/c3ref/step.html step :: Statement -> IO (Either Error StepResult) -- | https://www.sqlite.org/c3ref/step.html -- -- Faster step for statements that don't callback to Haskell functions -- (e.g. by using custom SQL functions). stepNoCB :: Statement -> IO (Either Error StepResult) -- | https://www.sqlite.org/c3ref/reset.html -- -- Warning: -- --
-- >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 https://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 -- | Number of arguments of a user defined SQL function. newtype ArgCount ArgCount :: Int -> ArgCount -- | Index of an argument to a custom function. Indices start from 0. type ArgIndex = ArgCount instance GHC.Show.Show Database.SQLite3.Direct.Backup instance GHC.Classes.Eq Database.SQLite3.Direct.Backup instance GHC.Show.Show Database.SQLite3.Direct.Blob instance GHC.Classes.Eq Database.SQLite3.Direct.Blob instance GHC.Show.Show Database.SQLite3.Direct.FuncContext instance GHC.Classes.Eq Database.SQLite3.Direct.FuncContext instance GHC.Base.Monoid Database.SQLite3.Direct.Utf8 instance GHC.Base.Semigroup Database.SQLite3.Direct.Utf8 instance GHC.Classes.Ord Database.SQLite3.Direct.Utf8 instance GHC.Classes.Eq Database.SQLite3.Direct.Utf8 instance GHC.Show.Show Database.SQLite3.Direct.BackupStepResult instance GHC.Classes.Eq Database.SQLite3.Direct.BackupStepResult instance GHC.Show.Show Database.SQLite3.Direct.StepResult instance GHC.Classes.Eq Database.SQLite3.Direct.StepResult instance GHC.Show.Show Database.SQLite3.Direct.Statement instance GHC.Classes.Eq Database.SQLite3.Direct.Statement instance GHC.Show.Show Database.SQLite3.Direct.Database instance GHC.Classes.Eq Database.SQLite3.Direct.Database instance GHC.Show.Show Database.SQLite3.Direct.Utf8 instance Data.String.IsString Database.SQLite3.Direct.Utf8 module Database.SQLite3 -- | https://www.sqlite.org/c3ref/open.html open :: Text -> IO Database -- | https://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 " Number of columns, which is the number of items in the following lists. This will be the same for every row." -> [Text] " List of column names. This will be the same for every row." -> [Maybe Text] " List of column values, as returned by 'columnText'." -> IO () -- | https://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 -- | https://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 -- | https://www.sqlite.org/c3ref/step.html step :: Statement -> IO StepResult -- | https://www.sqlite.org/c3ref/step.html -- -- Faster step for statements that don't callback to Haskell functions -- (e.g. by using custom SQL functions). stepNoCB :: Statement -> IO StepResult -- | https://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 () -- | https://www.sqlite.org/c3ref/finalize.html -- -- Like reset, finalize never throws an exception. finalize :: Statement -> IO () -- | https://www.sqlite.org/c3ref/clear_bindings.html -- -- Set all parameters in the prepared statement to null. clearBindings :: Statement -> IO () -- | https://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 -- | https://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) -- | https://www.sqlite.org/c3ref/column_count.html columnCount :: Statement -> IO ColumnCount -- | https://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 () -- | Convenience function for binding named values to all parameters. This -- will fail if the list has the wrong number of parameters or if -- an unknown name is used. -- -- Example: -- --
-- stmt <- prepare conn "SELECT :foo + :bar"
-- bindNamed stmt [(":foo", SQLInteger 1), (":bar", SQLInteger 2)]
--
bindNamed :: Statement -> [(Text, 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 ()
bindZeroBlob :: Statement -> ParamIndex -> Int -> 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
-- https://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
-- | https://www.sqlite.org/c3ref/last_insert_rowid.html
lastInsertRowId :: Database -> IO Int64
-- | https://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
-- | https://sqlite.org/c3ref/create_function.html
--
-- Create a custom SQL function or redefine the behavior of an existing
-- function. If the function is deterministic, i.e. if it always returns
-- the same result given the same input, you can set the boolean flag to
-- let sqlite perform additional optimizations.
createFunction :: Database -> Text -> Maybe ArgCount -> Bool -> (FuncContext -> FuncArgs -> IO ()) -> IO ()
-- | Like createFunction except that it creates an aggregate
-- function.
createAggregate :: Database -> Text -> Maybe ArgCount -> a -> (FuncContext -> FuncArgs -> a -> IO a) -> (FuncContext -> a -> IO ()) -> IO ()
-- | Delete an SQL function (scalar or aggregate).
deleteFunction :: Database -> Text -> Maybe ArgCount -> IO ()
funcArgCount :: FuncArgs -> ArgCount
funcArgType :: FuncArgs -> ArgIndex -> IO ColumnType
funcArgInt64 :: FuncArgs -> ArgIndex -> IO Int64
funcArgDouble :: FuncArgs -> ArgIndex -> IO Double
funcArgText :: FuncArgs -> ArgIndex -> IO Text
funcArgBlob :: FuncArgs -> ArgIndex -> IO ByteString
funcResultSQLData :: FuncContext -> SQLData -> IO ()
funcResultInt64 :: FuncContext -> Int64 -> IO ()
funcResultDouble :: FuncContext -> Double -> IO ()
funcResultText :: FuncContext -> Text -> IO ()
funcResultBlob :: FuncContext -> ByteString -> IO ()
funcResultZeroBlob :: FuncContext -> Int -> IO ()
funcResultNull :: FuncContext -> IO ()
-- | https://www.sqlite.org/c3ref/context_db_handle.html
getFuncContextDatabase :: FuncContext -> IO Database
-- | https://www.sqlite.org/c3ref/create_collation.html
createCollation :: Database -> Text -> (Text -> Text -> Ordering) -> IO ()
-- | Delete a collation.
deleteCollation :: Database -> Text -> IO ()
-- | https://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
-- | https://www.sqlite.org/c3ref/blob_open.html
--
-- Open a blob for incremental I/O.
blobOpen :: Database -> Text -> Text -> Text -> Int64 -> Bool -> IO Blob
-- | https://www.sqlite.org/c3ref/blob_close.html
blobClose :: Blob -> IO ()
-- | https://www.sqlite.org/c3ref/blob_reopen.html
blobReopen :: Blob -> Int64 -> IO ()
-- | https://www.sqlite.org/c3ref/blob_bytes.html
blobBytes :: Blob -> IO Int
-- | https://www.sqlite.org/c3ref/blob_read.html
blobRead :: Blob -> Int -> Int -> IO ByteString
blobReadBuf :: Blob -> Ptr a -> Int -> Int -> IO ()
-- | https://www.sqlite.org/c3ref/blob_write.html
blobWrite :: Blob -> ByteString -> Int -> IO ()
backupInit :: Database -> Text -> Database -> Text -> IO Backup
backupFinish :: Backup -> IO ()
backupStep :: Backup -> Int -> IO BackupStepResult
-- |
-- https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupremaining
backupRemaining :: Backup -> IO Int
-- |
-- https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backuppagecount
backupPagecount :: Backup -> IO Int
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
-- | https://www.sqlite.org/c3ref/c_blob.html
data ColumnType
IntegerColumn :: ColumnType
FloatColumn :: ColumnType
TextColumn :: ColumnType
BlobColumn :: ColumnType
NullColumn :: ColumnType
-- | The context in which a custom SQL function is executed.
data FuncContext
-- | The arguments of a custom SQL function.
data FuncArgs
-- | The type of blob handles used for incremental blob I/O
data Blob
-- | A handle for an online backup process.
data Backup
data StepResult
Row :: StepResult
Done :: StepResult
data BackupStepResult
-- | There are still more pages to be copied.
BackupOK :: BackupStepResult
-- | All pages were successfully copied.
BackupDone :: BackupStepResult
-- | https://www.sqlite.org/c3ref/c_abort.html
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
-- | Notifications from sqlite3_log()
ErrorNotice :: Error
-- | Warnings from sqlite3_log()
ErrorWarning :: 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 https://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 -- | Number of arguments of a user defined SQL function. newtype ArgCount ArgCount :: Int -> ArgCount -- | Index of an argument to a custom function. Indices start from 0. type ArgIndex = ArgCount instance GHC.Classes.Eq Database.SQLite3.SQLError instance GHC.Show.Show Database.SQLite3.SQLData instance GHC.Classes.Eq Database.SQLite3.SQLData instance GHC.Show.Show Database.SQLite3.SQLError instance GHC.Exception.Type.Exception Database.SQLite3.SQLError