-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Backend for the persistent library using sqlite3.
--
-- This package includes a thin sqlite3 wrapper based on the
-- direct-sqlite package, as well as the entire C library, so there are
-- no system dependencies.
@package persistent-sqlite
@version 2.6.3.2
-- | A port of the direct-sqlite package for dealing directly with
-- PersistValues.
module Database.Sqlite
data Connection
data Statement
data Error
ErrorOK :: Error
ErrorError :: Error
ErrorInternal :: Error
ErrorPermission :: Error
ErrorAbort :: Error
ErrorBusy :: Error
ErrorLocked :: Error
ErrorNoMemory :: Error
ErrorReadOnly :: Error
ErrorInterrupt :: Error
ErrorIO :: Error
ErrorNotFound :: Error
ErrorCorrupt :: Error
ErrorFull :: Error
ErrorCan'tOpen :: Error
ErrorProtocol :: Error
ErrorEmpty :: Error
ErrorSchema :: Error
ErrorTooBig :: Error
ErrorConstraint :: Error
ErrorMismatch :: Error
ErrorMisuse :: Error
ErrorNoLargeFileSupport :: Error
ErrorAuthorization :: Error
ErrorFormat :: Error
ErrorRange :: Error
ErrorNotAConnection :: Error
ErrorRow :: Error
ErrorDone :: Error
-- | A custom exception type to make it easier to catch exceptions.
data SqliteException
SqliteException :: !Error -> !Text -> !Text -> SqliteException
[seError] :: SqliteException -> !Error
[seFunctionName] :: SqliteException -> !Text
[seDetails] :: SqliteException -> !Text
data StepResult
Row :: StepResult
Done :: StepResult
-- | Configuration option for SQLite to be used together with the
-- config function.
data Config
-- | A function to be used for logging
ConfigLogFn :: LogFunction -> Config
data LogFunction
-- | Return type of the status function
data SqliteStatus
SqliteStatus :: Maybe Int -> Maybe Int -> SqliteStatus
-- | The current value of the parameter. Some parameters do not record
-- current value.
[sqliteStatusCurrent] :: SqliteStatus -> Maybe Int
-- | The highest recorded value. Some parameters do not record the highest
-- value.
[sqliteStatusHighwater] :: SqliteStatus -> Maybe Int
-- | Run-time status parameter that can be returned by status
-- function.
data SqliteStatusVerb
-- | This parameter is the current amount of memory checked out using
-- sqlite3_malloc(), either directly or indirectly. The figure includes
-- calls made to sqlite3_malloc() by the application and internal memory
-- usage by the SQLite library. Scratch memory controlled by
-- SQLITE_CONFIG_SCRATCH and auxiliary page-cache memory controlled by
-- SQLITE_CONFIG_PAGECACHE is not included in this parameter. The amount
-- returned is the sum of the allocation sizes as reported by the xSize
-- method in sqlite3_mem_methods.
SqliteStatusMemoryUsed :: SqliteStatusVerb
-- | This parameter returns the number of pages used out of the pagecache
-- memory allocator that was configured using SQLITE_CONFIG_PAGECACHE.
-- The value returned is in pages, not in bytes.
SqliteStatusPagecacheUsed :: SqliteStatusVerb
-- | This parameter returns the number of bytes of page cache allocation
-- which could not be satisfied by the SQLITE_CONFIG_PAGECACHE buffer and
-- where forced to overflow to sqlite3_malloc(). The returned value
-- includes allocations that overflowed because they where too large
-- (they were larger than the "sz" parameter to SQLITE_CONFIG_PAGECACHE)
-- and allocations that overflowed because no space was left in the page
-- cache.
SqliteStatusPagecacheOverflow :: SqliteStatusVerb
-- | This parameter returns the number of allocations used out of the
-- scratch memory allocator configured using SQLITE_CONFIG_SCRATCH. The
-- value returned is in allocations, not in bytes. Since a single thread
-- may only have one scratch allocation outstanding at time, this
-- parameter also reports the number of threads using scratch memory at
-- the same time.
SqliteStatusScratchUsed :: SqliteStatusVerb
-- | This parameter returns the number of bytes of scratch memory
-- allocation which could not be satisfied by the SQLITE_CONFIG_SCRATCH
-- buffer and where forced to overflow to sqlite3_malloc(). The values
-- returned include overflows because the requested allocation was too
-- larger (that is, because the requested allocation was larger than the
-- "sz" parameter to SQLITE_CONFIG_SCRATCH) and because no scratch buffer
-- slots were available.
SqliteStatusScratchOverflow :: SqliteStatusVerb
-- | This parameter records the largest memory allocation request handed to
-- sqlite3_malloc() or sqlite3_realloc() (or their internal equivalents).
-- Only the value returned in sqliteStatusHighwater field of
-- SqliteStatus record is of interest. The value written into the
-- sqliteStatusCurrent field is Nothing.
SqliteStatusMallocSize :: SqliteStatusVerb
-- | This parameter records the largest memory allocation request handed to
-- pagecache memory allocator. Only the value returned in the
-- sqliteStatusHighwater field of SqliteStatus record is of
-- interest. The value written into the sqliteStatusCurrent field
-- is Nothing.
SqliteStatusPagecacheSize :: SqliteStatusVerb
-- | This parameter records the largest memory allocation request handed to
-- scratch memory allocator. Only the value returned in the
-- sqliteStatusHighwater field of SqliteStatus record is of
-- interest. The value written into the sqliteStatusCurrent field
-- is Nothing.
SqliteStatusScratchSize :: SqliteStatusVerb
-- | This parameter records the number of separate memory allocations
-- currently checked out.
SqliteStatusMallocCount :: SqliteStatusVerb
open :: Text -> IO Connection
close :: Connection -> IO ()
prepare :: Connection -> Text -> IO Statement
step :: Connection -> 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
-- | 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.
mkLogFunction :: (Int -> String -> IO ()) -> IO LogFunction
-- | Releases a native FunPtr for the LogFunction.
freeLogFunction :: LogFunction -> 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.
config :: Config -> IO ()
-- | Retrieves runtime status information about the performance of SQLite,
-- and optionally resets various highwater marks. The first argument is a
-- status parameter to measure, the second is reset flag. If reset flag
-- is True then the highest recorded value is reset after being returned
-- from this function.
status :: SqliteStatusVerb -> Bool -> IO SqliteStatus
-- | Sets and/or queries the soft limit on the amount of heap memory that
-- may be allocated by SQLite. If the argument is zero then the soft heap
-- limit is disabled. If the argument is negative then no change is made
-- to the soft heap limit. Hence, the current size of the soft heap limit
-- can be determined by invoking this function with a negative argument.
softHeapLimit :: Int64 -> IO Int64
instance GHC.Show.Show Database.Sqlite.SqliteStatus
instance GHC.Classes.Eq Database.Sqlite.SqliteStatus
instance GHC.Show.Show Database.Sqlite.ColumnType
instance GHC.Classes.Eq Database.Sqlite.ColumnType
instance GHC.Show.Show Database.Sqlite.StepResult
instance GHC.Classes.Eq Database.Sqlite.StepResult
instance GHC.Show.Show Database.Sqlite.Error
instance GHC.Classes.Eq Database.Sqlite.Error
instance GHC.Show.Show Database.Sqlite.SqliteException
instance GHC.Exception.Exception Database.Sqlite.SqliteException
-- | A sqlite backend for persistent.
--
-- Note: If you prepend WAL=off to your connection string, it
-- will disable the write-ahead log. This functionality is now deprecated
-- in favour of using SqliteConnectionInfo.
module Database.Persist.Sqlite
-- | Run the given action with a connection pool.
--
-- Like createSqlitePool, this should not be used with
-- :memory:.
withSqlitePool :: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) => Text -> Int -> (Pool backend -> m a) -> m a
-- | Run the given action with a connection pool.
--
-- Like createSqlitePool, this should not be used with
-- :memory:.
withSqlitePoolInfo :: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) => SqliteConnectionInfo -> Int -> (Pool backend -> m a) -> m a
withSqliteConn :: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) => Text -> (backend -> m a) -> m a
withSqliteConnInfo :: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) => SqliteConnectionInfo -> (backend -> m a) -> m a
-- | Create a pool of SQLite connections.
--
-- Note that this should not be used with the :memory:
-- connection string, as the pool will regularly remove connections,
-- destroying your database. Instead, use withSqliteConn.
createSqlitePool :: (MonadIO m, MonadLogger m, MonadBaseControl IO m, IsSqlBackend backend) => Text -> Int -> m (Pool backend)
-- | Create a pool of SQLite connections.
--
-- Note that this should not be used with the :memory:
-- connection string, as the pool will regularly remove connections,
-- destroying your database. Instead, use withSqliteConn.
createSqlitePoolFromInfo :: (MonadIO m, MonadLogger m, MonadBaseControl IO m, IsSqlBackend backend) => SqliteConnectionInfo -> Int -> m (Pool backend)
-- | Information required to setup a connection pool.
data SqliteConf
SqliteConf :: Text -> Int -> SqliteConf
[sqlDatabase] :: SqliteConf -> Text
[sqlPoolSize] :: SqliteConf -> Int
SqliteConfInfo :: SqliteConnectionInfo -> Int -> SqliteConf
[sqlConnInfo] :: SqliteConf -> SqliteConnectionInfo
[sqlPoolSize] :: SqliteConf -> Int
-- | Information required to connect to a sqlite database. We export lenses
-- instead of fields to avoid being limited to the current
-- implementation.
data SqliteConnectionInfo
-- | Creates a SqliteConnectionInfo from a connection string, with the
-- default settings.
mkSqliteConnectionInfo :: Text -> SqliteConnectionInfo
sqlConnectionStr :: Lens' SqliteConnectionInfo Text
walEnabled :: Lens' SqliteConnectionInfo Bool
fkEnabled :: Lens' SqliteConnectionInfo Bool
-- | A convenience helper which creates a new database connection and runs
-- the given block, handling MonadResource and
-- MonadLogger requirements. Note that all log messages are
-- discarded.
runSqlite :: (MonadBaseControl IO m, MonadIO m, IsSqlBackend backend) => Text -> ReaderT backend (NoLoggingT (ResourceT m)) a -> m a
-- | A convenience helper which creates a new database connection and runs
-- the given block, handling MonadResource and
-- MonadLogger requirements. Note that all log messages are
-- discarded.
runSqliteInfo :: (MonadBaseControl IO m, MonadIO m, IsSqlBackend backend) => SqliteConnectionInfo -> ReaderT backend (NoLoggingT (ResourceT m)) a -> m a
-- | Wrap up a raw Connection as a Persistent SQL Connection.
wrapConnection :: (IsSqlBackend backend) => Connection -> LogFunc -> IO backend
-- | Wrap up a raw Connection as a Persistent SQL Connection,
-- allowing full control over WAL and FK constraints.
wrapConnectionInfo :: (IsSqlBackend backend) => SqliteConnectionInfo -> Connection -> LogFunc -> IO backend
-- | Mock a migration even when the database is not present. This function
-- performs the same functionality of printMigration with the
-- difference that an actualy database isn't needed for it.
mockMigration :: Migration -> IO ()
instance Data.Aeson.Types.FromJSON.FromJSON Database.Persist.Sqlite.SqliteConnectionInfo
instance GHC.Show.Show Database.Persist.Sqlite.SqliteConf
instance GHC.Show.Show Database.Persist.Sqlite.SqliteConnectionInfo
instance Data.Aeson.Types.FromJSON.FromJSON Database.Persist.Sqlite.SqliteConf
instance Database.Persist.Class.PersistConfig.PersistConfig Database.Persist.Sqlite.SqliteConf