| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
DBPipe.SQLite
Synopsis
- module Database.SQLite.Simple
- class ToField a where
- class FromField a where
- fromField :: FieldParser a
- class ToRow a where
- class FromRow a where
- data DBPipeEnv
- data DBPipeOpts = DBPipeOpts {}
- dbPipeOptsDef :: DBPipeOpts
- runPipe :: MonadIO m => DBPipeEnv -> m ()
- newDBPipeEnv :: MonadIO m => DBPipeOpts -> FilePath -> m DBPipeEnv
- data DBPipeM (m :: Type -> Type) a
- select :: forall b args a (m :: Type -> Type). (ToQuery a b, FromRow b, ToRow args, MonadIO m) => a -> args -> DBPipeM m [b]
- select_ :: forall a b (m :: Type -> Type). (ToQuery a b, FromRow b, MonadIO m) => a -> DBPipeM m [b]
- update :: forall {k} a args (b :: k) (m :: Type -> Type). (ToQuery a b, ToRow args, MonadIO m) => a -> args -> DBPipeM m ()
- update_ :: forall a (m :: Type -> Type). (ToQuery a (), MonadIO m) => a -> DBPipeM m ()
- insert :: forall {k} a args (b :: k) (m :: Type -> Type). (ToQuery a b, ToRow args, MonadIO m) => a -> args -> DBPipeM m ()
- insert_ :: forall a (m :: Type -> Type). (ToQuery a (), MonadIO m) => a -> DBPipeM m ()
- ddl :: forall a (m :: Type -> Type). (ToQuery a (), MonadIO m) => a -> DBPipeM m ()
- transactional :: forall a (m :: Type -> Type). MonadUnliftIO m => DBPipeM m a -> DBPipeM m ()
- transactional_ :: forall a m. MonadUnliftIO m => DBPipeEnv -> Connection -> m a -> m ()
- commitAll :: forall (m :: Type -> Type). MonadIO m => DBPipeM m ()
- withDB :: forall a m. MonadIO m => DBPipeEnv -> DBPipeM m a -> m a
- shutdown :: MonadIO m => Bool -> DBPipeEnv -> m ()
Documentation
module Database.SQLite.Simple
A type that may be used as a single parameter to a SQL query.
Instances
A type that may be converted from a SQL type.
Methods
fromField :: FieldParser a #
Convert a SQL value to a Haskell value.
Returns a list of exceptions if the conversion fails. In the case of
library instances, this will usually be a single ResultError, but
may be a UnicodeException.
Implementations of fromField should not retain any references to
the Field nor the ByteString arguments after the result has
been evaluated to WHNF. Such a reference causes the entire
LibPQ. to be retained.Result
For example, the instance for ByteString uses copy to avoid
such a reference, and that using bytestring functions such as drop
and takeWhile alone will also trigger this memory leak.
Instances
A collection type that can be turned into a list of SQLData
elements.
Since version 0.4.18.1 it is possible in some cases to derive a
generic implementation for ToRow. Refer to the documentation for
FromRow to see how this can be
done.
Minimal complete definition
Nothing
Methods
ToField a collection of values.
Instances
A collection type that can be converted from a sequence of fields. Instances are provided for tuples up to 10 elements and lists of any length.
Note that instances can defined outside of sqlite-simple, which is often useful. For example, here's an instance for a user-defined pair:
data User = User { name :: String, fileQuota :: Int }
instance FromRow User where
fromRow = User <$> field <*> field
The number of calls to field must match the number of fields returned
in a single row of the query result. Otherwise, a ConversionFailed
exception will be thrown.
Note the caveats associated with user-defined implementations of
fromRow.
Generic implementation
Since version 0.4.18.1 it is possible in some cases to derive a
generic implementation for FromRow. With a Generic instance
for User, the example above could be written:
instance FromRow User where
With -XDeriveAnyClass -XDerivingStrategies the same can be written:
deriving anyclass instance FromRow User
For more details refer to GFromRow.
Minimal complete definition
Nothing
Instances
data DBPipeOpts Source #
Constructors
| DBPipeOpts | |
newDBPipeEnv :: MonadIO m => DBPipeOpts -> FilePath -> m DBPipeEnv Source #
data DBPipeM (m :: Type -> Type) a Source #
Instances
| MonadTrans DBPipeM Source # | |
Defined in DBPipe.SQLite | |
| Monad m => MonadReader DBPipeEnv (DBPipeM m) Source # | |
| MonadIO m => MonadIO (DBPipeM m) Source # | |
Defined in DBPipe.SQLite | |
| Applicative m => Applicative (DBPipeM m) Source # | |
| Functor m => Functor (DBPipeM m) Source # | |
| Monad m => Monad (DBPipeM m) Source # | |
| MonadUnliftIO m => MonadUnliftIO (DBPipeM m) Source # | |
Defined in DBPipe.SQLite | |
select :: forall b args a (m :: Type -> Type). (ToQuery a b, FromRow b, ToRow args, MonadIO m) => a -> args -> DBPipeM m [b] Source #
select_ :: forall a b (m :: Type -> Type). (ToQuery a b, FromRow b, MonadIO m) => a -> DBPipeM m [b] Source #
update :: forall {k} a args (b :: k) (m :: Type -> Type). (ToQuery a b, ToRow args, MonadIO m) => a -> args -> DBPipeM m () Source #
insert :: forall {k} a args (b :: k) (m :: Type -> Type). (ToQuery a b, ToRow args, MonadIO m) => a -> args -> DBPipeM m () Source #
transactional :: forall a (m :: Type -> Type). MonadUnliftIO m => DBPipeM m a -> DBPipeM m () Source #
transactional_ :: forall a m. MonadUnliftIO m => DBPipeEnv -> Connection -> m a -> m () Source #