-- 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


-- | A port of the direct-sqlite package for dealing directly with
--   <a>PersistValue</a>s.
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.
--   
--   Since 2.1.3
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
--   <a>config</a> function.
--   
--   Since 2.1.4
data Config

-- | A function to be used for logging
ConfigLogFn :: LogFunction -> Config

-- | Since 2.1.4
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

-- | Wraps a given function to a <a>LogFunction</a> to be further used with
--   <a>ConfigLogFn</a>. First argument of given function will take error
--   code, second - log message. Returned value should be released with
--   <a>freeLogFunction</a> when no longer required.
mkLogFunction :: (Int -> String -> IO ()) -> IO LogFunction

-- | Releases a native FunPtr for the <a>LogFunction</a>.
--   
--   Since 2.1.4
freeLogFunction :: LogFunction -> IO ()

-- | Sets SQLite global configuration parameter. See SQLite documentation
--   for the <a>sqlite3_config</a> function. In short, this must be called
--   prior to any other SQLite function if you want the call to succeed.
--   
--   Since 2.1.4
config :: Config -> IO ()
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 <tt>WAL=off </tt> to your connection string, it
--   will disable the write-ahead log. For more information, see
--   <a>https://github.com/yesodweb/persistent/issues/363</a>.
module Database.Persist.Sqlite

-- | Run the given action with a connection pool.
--   
--   Like <a>createSqlitePool</a>, this should not be used with
--   <tt>:memory:</tt>.
withSqlitePool :: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) => Text -> Int -> (Pool backend -> m a) -> m a
withSqliteConn :: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) => Text -> (backend -> m a) -> m a

-- | Create a pool of SQLite connections.
--   
--   Note that this should not be used with the <tt>:memory:</tt>
--   connection string, as the pool will regularly remove connections,
--   destroying your database. Instead, use <a>withSqliteConn</a>.
createSqlitePool :: (MonadIO m, MonadLogger m, MonadBaseControl IO m, IsSqlBackend backend) => Text -> Int -> m (Pool backend)

-- | Information required to connect to a sqlite database
data SqliteConf
SqliteConf :: Text -> Int -> SqliteConf
[sqlDatabase] :: SqliteConf -> Text
[sqlPoolSize] :: SqliteConf -> Int

-- | A convenience helper which creates a new database connection and runs
--   the given block, handling <tt>MonadResource</tt> and
--   <tt>MonadLogger</tt> requirements. Note that all log messages are
--   discarded.
--   
--   Since 1.1.4
runSqlite :: (MonadBaseControl IO m, MonadIO m, IsSqlBackend backend) => Text -> ReaderT backend (NoLoggingT (ResourceT m)) a -> m a

-- | Wrap up a raw <a>Connection</a> as a Persistent SQL <a>Connection</a>.
--   
--   Since 1.1.5
wrapConnection :: (IsSqlBackend backend) => Connection -> LogFunc -> IO backend

-- | Mock a migration even when the database is not present. This function
--   performs the same functionality of <a>printMigration</a> with the
--   difference that an actualy database isn't needed for it.
mockMigration :: Migration -> IO ()
instance GHC.Show.Show Database.Persist.Sqlite.SqliteConf
instance Data.Aeson.Types.Class.FromJSON Database.Persist.Sqlite.SqliteConf
instance Database.Persist.Class.PersistConfig.PersistConfig Database.Persist.Sqlite.SqliteConf
