Safe Haskell | None |
---|---|
Language | Haskell2010 |
The implementation of sqlite-easy.
This module is unstable and may change at any time.
Synopsis
- newtype ConnectionString = ConnectionString {}
- createSqlitePool :: ConnectionString -> IO (Pool Database)
- createSqlitePoolWith :: ConnectionString -> [SQL] -> IO (Pool Database)
- openWith :: ConnectionString -> [SQL] -> IO Database
- defaultPragmas :: [SQL]
- withDb :: ConnectionString -> SQLite a -> IO a
- withDatabase :: Database -> SQLite a -> IO a
- withPool :: Pool Database -> SQLite a -> IO a
- newtype SQL = SQL {}
- run :: SQL -> SQLite [[SQLData]]
- runWith :: SQL -> [SQLData] -> SQLite [[SQLData]]
- fetchAll :: Statement -> IO [[SQLData]]
- newtype SQLite a = SQLite {
- unSQLite :: SQLiteStuff -> IO a
- data SQLiteStuff = SQLiteStuff {}
- getDB :: SQLite Database
- runSQLite :: Database -> SQLite a -> IO a
- transaction :: Typeable a => SQLite a -> SQLite a
- asTransaction' :: Database -> IO a -> IO a
- rollback :: Typeable a => a -> SQLite a
- rollbackAll :: Typeable a => a -> SQLite a
- data RollbackCurrent a = RollbackCurrent a
- data RollbackAll a = RollbackAll a
Connection
newtype ConnectionString Source #
A SQLite3 connection string
Instances
IsString ConnectionString Source # | |
Defined in Database.Sqlite.Easy.Internal fromString :: String -> ConnectionString # | |
Show ConnectionString Source # | |
Defined in Database.Sqlite.Easy.Internal showsPrec :: Int -> ConnectionString -> ShowS # show :: ConnectionString -> String # showList :: [ConnectionString] -> ShowS # |
createSqlitePool :: ConnectionString -> IO (Pool Database) Source #
Create a pool of a sqlite3 db with a specific connection string. This also sets a few default pragmas.
createSqlitePoolWith :: ConnectionString -> [SQL] -> IO (Pool Database) Source #
Create a pool of a sqlite3 db with a specific connection string. This will also run the supplied SQL statements after establishing each connection.
openWith :: ConnectionString -> [SQL] -> IO Database Source #
Open a connection to a database, run the supplied statements, and return the connection.
defaultPragmas :: [SQL] Source #
Default pragmas to be set when opening a connection from a pool.
withDb :: ConnectionString -> SQLite a -> IO a Source #
Open a database, run some stuff, close the database.
withDatabase :: Database -> SQLite a -> IO a Source #
Use an active database connection to run some stuff on a database.
withPool :: Pool Database -> SQLite a -> IO a Source #
Use a resource pool to run some stuff on a database.
Execution
A SQL statement
runWith :: SQL -> [SQLData] -> SQLite [[SQLData]] Source #
Run a SQL statement with certain parameters on a database and fetch the results.
Transaction
The type of actions to run on a SQLite database.
In essence, it is almost the same as Database -> IO a
.
SQLite
actions can be created with the run
and runWith
functions, and can be composed using the type class instances.
SQLite
actions can be run with the withDb
, withDatabase
,
and withPool
functions.
SQLite | |
|
Instances
MonadFail SQLite Source # | |
Defined in Database.Sqlite.Easy.Internal | |
MonadIO SQLite Source # | |
Defined in Database.Sqlite.Easy.Internal | |
Applicative SQLite Source # | |
Functor SQLite Source # | |
Monad SQLite Source # | |
MonadUnliftIO SQLite Source # | |
Defined in Database.Sqlite.Easy.Internal | |
Monoid a => Monoid (SQLite a) Source # | |
Semigroup a => Semigroup (SQLite a) Source # | |
data SQLiteStuff Source #
transaction :: Typeable a => SQLite a -> SQLite a Source #
Run operations as a transaction. If the action throws an error, the transaction is rolled back. For more information, visit: https://www.sqlite.org/lang_transaction.html
rollback :: Typeable a => a -> SQLite a Source #
Rollback the current (inner-most) transaction by supplying the return value. To be used inside transactions.
rollbackAll :: Typeable a => a -> SQLite a Source #
Rollback all transaction structure by supplying the return value. To be used inside transactions.
data RollbackCurrent a Source #
Instances
Typeable a => Exception (RollbackCurrent a) Source # | |
Defined in Database.Sqlite.Easy.Internal toException :: RollbackCurrent a -> SomeException # fromException :: SomeException -> Maybe (RollbackCurrent a) # displayException :: RollbackCurrent a -> String # | |
Show (RollbackCurrent a) Source # | |
Defined in Database.Sqlite.Easy.Internal showsPrec :: Int -> RollbackCurrent a -> ShowS # show :: RollbackCurrent a -> String # showList :: [RollbackCurrent a] -> ShowS # |
data RollbackAll a Source #
Instances
Typeable a => Exception (RollbackAll a) Source # | |
Defined in Database.Sqlite.Easy.Internal toException :: RollbackAll a -> SomeException # fromException :: SomeException -> Maybe (RollbackAll a) # displayException :: RollbackAll a -> String # | |
Show (RollbackAll a) Source # | |
Defined in Database.Sqlite.Easy.Internal showsPrec :: Int -> RollbackAll a -> ShowS # show :: RollbackAll a -> String # showList :: [RollbackAll a] -> ShowS # |