Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | oleg@pobox.com, alistair@abayley.org |
Simple wrappers for Sqlite functions (FFI).
- data DBHandleStruct = DBHandleStruct
- type DBHandle = Ptr DBHandleStruct
- data StmtStruct = StmtStruct
- type StmtHandle = Ptr StmtStruct
- type Blob = Ptr Word8
- type SqliteCallback a = FunPtr (Ptr a -> CInt -> Ptr CString -> Ptr CString -> IO Int)
- type FreeFunPtr = FunPtr (Ptr Word8 -> IO ())
- data SqliteException = SqliteException Int String
- catchSqlite :: IO a -> (SqliteException -> IO a) -> IO a
- throwSqlite :: SqliteException -> a
- sqliteOK :: CInt
- sqliteERROR :: CInt
- sqliteROW :: CInt
- sqliteDONE :: CInt
- cStr :: CStringLen -> CString
- cStrLen :: CStringLen -> CInt
- type UTF16CString = CString
- type UTF8CString = CString
- sqliteOpen :: UTF8CString -> Ptr DBHandle -> IO CInt
- sqliteClose :: DBHandle -> IO CInt
- sqlitePrepare :: DBHandle -> UTF8CString -> CInt -> Ptr StmtHandle -> Ptr CString -> IO CInt
- sqliteExec :: DBHandle -> UTF8CString -> SqliteCallback a -> Ptr a -> Ptr CString -> IO CInt
- sqliteStep :: StmtHandle -> IO CInt
- sqliteFinalise :: StmtHandle -> IO CInt
- sqliteReset :: StmtHandle -> IO CInt
- sqliteChanges :: DBHandle -> IO CInt
- sqliteLastInsertRowid :: DBHandle -> IO CLLong
- sqliteFree :: Ptr a -> IO ()
- sqliteErrcode :: DBHandle -> IO CInt
- sqliteErrmsg :: DBHandle -> IO UTF8CString
- sqliteColumnBytes :: StmtHandle -> CInt -> IO Int
- sqliteColumnBlob :: StmtHandle -> CInt -> IO Blob
- sqliteColumnDouble :: StmtHandle -> CInt -> IO CDouble
- sqliteColumnInt :: StmtHandle -> CInt -> IO CInt
- sqliteColumnInt64 :: StmtHandle -> CInt -> IO CLLong
- sqliteColumnText :: StmtHandle -> CInt -> IO UTF8CString
- sqliteColumnText16 :: StmtHandle -> CInt -> IO UTF16CString
- sqliteBindBlob :: StmtHandle -> CInt -> Blob -> CInt -> FreeFunPtr -> IO CInt
- sqliteBindDouble :: StmtHandle -> CInt -> CDouble -> IO CInt
- sqliteBindInt :: StmtHandle -> CInt -> CInt -> IO CInt
- sqliteBindInt64 :: StmtHandle -> CInt -> CLLong -> IO CInt
- sqliteBindNull :: StmtHandle -> CInt -> IO CInt
- sqliteBindText :: StmtHandle -> CInt -> UTF8CString -> CInt -> FreeFunPtr -> IO CInt
- sqliteBindText16 :: StmtHandle -> CInt -> UTF16CString -> CInt -> FreeFunPtr -> IO CInt
- getError :: DBHandle -> IO SqliteException
- getAndRaiseError :: Int -> DBHandle -> IO a
- errorTest :: DBHandle -> CInt -> IO a -> IO a
- testForError :: DBHandle -> CInt -> a -> IO a
- testForErrorWithPtr :: Storable a => DBHandle -> CInt -> Ptr a -> IO a
- openDb :: String -> IO DBHandle
- closeDb :: DBHandle -> IO ()
- stmtExec :: DBHandle -> String -> IO Int
- stmtChanges :: DBHandle -> IO Int
- stmtPrepare :: DBHandle -> String -> IO StmtHandle
- stmtFetch :: DBHandle -> StmtHandle -> IO CInt
- stmtFinalise :: DBHandle -> StmtHandle -> IO ()
- stmtReset :: DBHandle -> StmtHandle -> IO ()
- colValInt :: StmtHandle -> Int -> IO Int
- colValInt64 :: StmtHandle -> Int -> IO Int64
- colValDouble :: StmtHandle -> Int -> IO Double
- colValString :: StmtHandle -> Int -> IO (Maybe String)
- colValBlob :: StmtHandle -> Int -> IO (ForeignPtr Blob)
- bindDouble :: DBHandle -> StmtHandle -> Int -> Double -> IO ()
- bindInt :: DBHandle -> StmtHandle -> Int -> Int -> IO ()
- bindInt64 :: DBHandle -> StmtHandle -> Int -> Int64 -> IO ()
- bindNull :: DBHandle -> StmtHandle -> Int -> IO ()
- bindString :: DBHandle -> StmtHandle -> Int -> String -> IO ()
- bindBlob :: DBHandle -> StmtHandle -> Int -> Blob -> Int -> IO ()
Documentation
type DBHandle = Ptr DBHandleStructSource
type StmtHandle = Ptr StmtStructSource
catchSqlite :: IO a -> (SqliteException -> IO a) -> IO aSource
throwSqlite :: SqliteException -> aSource
cStr :: CStringLen -> CStringSource
cStrLen :: CStringLen -> CIntSource
type UTF16CString = CStringSource
type UTF8CString = CStringSource
sqliteOpen :: UTF8CString -> Ptr DBHandle -> IO CIntSource
sqliteClose :: DBHandle -> IO CIntSource
sqlitePrepare :: DBHandle -> UTF8CString -> CInt -> Ptr StmtHandle -> Ptr CString -> IO CIntSource
sqliteExec :: DBHandle -> UTF8CString -> SqliteCallback a -> Ptr a -> Ptr CString -> IO CIntSource
sqliteStep :: StmtHandle -> IO CIntSource
sqliteFinalise :: StmtHandle -> IO CIntSource
sqliteReset :: StmtHandle -> IO CIntSource
sqliteChanges :: DBHandle -> IO CIntSource
sqliteFree :: Ptr a -> IO ()Source
sqliteErrcode :: DBHandle -> IO CIntSource
sqliteColumnBytes :: StmtHandle -> CInt -> IO IntSource
sqliteColumnBlob :: StmtHandle -> CInt -> IO BlobSource
sqliteColumnDouble :: StmtHandle -> CInt -> IO CDoubleSource
sqliteColumnInt :: StmtHandle -> CInt -> IO CIntSource
sqliteColumnInt64 :: StmtHandle -> CInt -> IO CLLongSource
sqliteColumnText :: StmtHandle -> CInt -> IO UTF8CStringSource
sqliteColumnText16 :: StmtHandle -> CInt -> IO UTF16CStringSource
sqliteBindBlob :: StmtHandle -> CInt -> Blob -> CInt -> FreeFunPtr -> IO CIntSource
sqliteBindDouble :: StmtHandle -> CInt -> CDouble -> IO CIntSource
sqliteBindInt :: StmtHandle -> CInt -> CInt -> IO CIntSource
sqliteBindInt64 :: StmtHandle -> CInt -> CLLong -> IO CIntSource
sqliteBindNull :: StmtHandle -> CInt -> IO CIntSource
sqliteBindText :: StmtHandle -> CInt -> UTF8CString -> CInt -> FreeFunPtr -> IO CIntSource
sqliteBindText16 :: StmtHandle -> CInt -> UTF16CString -> CInt -> FreeFunPtr -> IO CIntSource
getAndRaiseError :: Int -> DBHandle -> IO aSource
testForError :: DBHandle -> CInt -> a -> IO aSource
stmtExec :: DBHandle -> String -> IO IntSource
This function is not used internally, so it's only provided as a user convenience.
stmtChanges :: DBHandle -> IO IntSource
stmtPrepare :: DBHandle -> String -> IO StmtHandleSource
stmtFinalise :: DBHandle -> StmtHandle -> IO ()Source
colValInt :: StmtHandle -> Int -> IO IntSource
Column numbers are zero-indexed, so subtract one from given index (we present a one-indexed interface).
colValInt64 :: StmtHandle -> Int -> IO Int64Source
colValDouble :: StmtHandle -> Int -> IO DoubleSource
colValString :: StmtHandle -> Int -> IO (Maybe String)Source
colValBlob :: StmtHandle -> Int -> IO (ForeignPtr Blob)Source
bindDouble :: DBHandle -> StmtHandle -> Int -> Double -> IO ()Source
bindString :: DBHandle -> StmtHandle -> Int -> String -> IO ()Source