persistent-sqlite-2.6: Backend for the persistent library using sqlite3.

Safe Haskell | None
Language | Haskell98

Database.Sqlite

Description

A port of the direct-sqlite package for dealing directly with `PersistValue`s.

Synopsis

- data Connection
- data Statement
- data Error
  - = ErrorOK
  - | ErrorError
  - | ErrorInternal
  - | ErrorPermission
  - | ErrorAbort
  - | ErrorBusy
  - | ErrorLocked
  - | ErrorNoMemory
  - | ErrorReadOnly
  - | ErrorInterrupt
  - | ErrorIO
  - | ErrorNotFound
  - | ErrorCorrupt
  - | ErrorFull
  - | ErrorCan'tOpen
  - | ErrorProtocol
  - | ErrorEmpty
  - | ErrorSchema
  - | ErrorTooBig
  - | ErrorConstraint
  - | ErrorMismatch
  - | ErrorMisuse
  - | ErrorNoLargeFileSupport
  - | ErrorAuthorization
  - | ErrorFormat
  - | ErrorRange
  - | ErrorNotAConnection
  - | ErrorRow
  - | ErrorDone
- data SqliteException = SqliteException {
  - seError :: !Error
  - seFunctionName :: !Text
  - seDetails :: !Text
  }
- data StepResult
  - = Row
  - | Done
- data Config = ConfigLogFn LogFunction
- data LogFunction
- open :: Text -> IO Connection
- close :: Connection -> IO ()
- prepare :: Connection -> Text -> IO Statement
- step :: Statement -> IO StepResult
- reset :: Connection -> Statement -> IO ()
- finalize :: Statement -> IO ()
- bindBlob :: Statement -> Int -> ByteString -> IO ()
- bindDouble :: Statement -> Int -> Double -> IO ()
- bindInt :: Statement -> Int -> Int -> IO ()
- bindInt64 :: Statement -> Int -> Int64 -> IO ()
- bindNull :: Statement -> Int -> IO ()
- bindText :: Statement -> Int -> Text -> IO ()
- bind :: Statement -> [PersistValue] -> IO ()
- column :: Statement -> Int -> IO PersistValue
- columns :: Statement -> IO [PersistValue]
- changes :: Connection -> IO Int64
- mkLogFunction :: (Int -> String -> IO ()) -> IO LogFunction
- freeLogFunction :: LogFunction -> IO ()
- config :: Config -> IO ()

# Documentation

data Connection #

data Statement #

data Error #

Constructors

ErrorOK |
ErrorError |
ErrorInternal |
ErrorPermission |
ErrorAbort |
ErrorBusy |
ErrorLocked |
ErrorNoMemory |
ErrorReadOnly |
ErrorInterrupt |
ErrorIO |
ErrorNotFound |
ErrorCorrupt |
ErrorFull |
ErrorCan'tOpen |
ErrorProtocol |
ErrorEmpty |
ErrorSchema |
ErrorTooBig |
ErrorConstraint |
ErrorMismatch |
ErrorMisuse |
ErrorNoLargeFileSupport |
ErrorAuthorization |
ErrorFormat |
ErrorRange |
ErrorNotAConnection |
ErrorRow |
ErrorDone |

Instances

Eq Error # |
Methods (==) :: Error -> Error -> Bool # (/=) :: Error -> Error -> Bool #
Show Error # |
Methods showsPrec :: Int -> Error -> ShowS # show :: Error -> String # showList :: [Error] -> ShowS #

data SqliteException #

A custom exception type to make it easier to catch exceptions.

Since 2.1.3

Constructors

SqliteException |
Fields seError :: !Error seFunctionName :: !Text seDetails :: !Text

Instances

Show SqliteException # |
Methods showsPrec :: Int -> SqliteException -> ShowS # show :: SqliteException -> String # showList :: [SqliteException] -> ShowS #
Exception SqliteException # |
Methods toException :: SqliteException -> SomeException # fromException :: SomeException -> Maybe SqliteException # displayException :: SqliteException -> String #

data StepResult #

Constructors

Row |
Done |

Instances

Eq StepResult # |
Methods (==) :: StepResult -> StepResult -> Bool # (/=) :: StepResult -> StepResult -> Bool #
Show StepResult # |
Methods showsPrec :: Int -> StepResult -> ShowS # show :: StepResult -> String # showList :: [StepResult] -> ShowS #

data Config #

Configuration option for SQLite to be used together with the `config` function.

Since 2.1.4

Constructors

ConfigLogFn LogFunction | A function to be used for logging

data LogFunction #

Since 2.1.4

open :: Text -> IO Connection #

close :: Connection -> IO () #

prepare :: Connection -> Text -> IO Statement #

step :: Statement -> IO StepResult #

reset :: Connection -> Statement -> IO () #

finalize :: Statement -> IO () #

bindBlob :: Statement -> Int -> ByteString -> IO () #

bindDouble :: Statement -> Int -> Double -> IO () #

bindInt :: Statement -> Int -> Int -> IO () #

bindInt64 :: Statement -> Int -> Int64 -> IO () #

bindNull :: Statement -> Int -> IO () #

bindText :: Statement -> Int -> Text -> IO () #

bind :: Statement -> [PersistValue] -> IO () #

column :: Statement -> Int -> IO PersistValue #

columns :: Statement -> IO [PersistValue] #

changes :: Connection -> IO Int64 #

mkLogFunction :: (Int -> String -> IO ()) -> IO LogFunction #

Wraps a given function to a `LogFunction` to be further used with `ConfigLogFn`. First argument of given function will take error code, second - log message. Returned value should be released with `freeLogFunction` when no longer required.

freeLogFunction :: LogFunction -> IO () #

Releases a native FunPtr for the `LogFunction`.

Since 2.1.4

config :: Config -> IO () #

Sets SQLite global configuration parameter. See SQLite documentation for the sqlite3_config function. In short, this must be called prior to any other SQLite function if you want the call to succeed.

Since 2.1.4