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

Safe Haskell | None
Language | Haskell2010

Database.Persist.Sqlite

Description

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.

Synopsis

- withSqlitePool :: (MonadUnliftIO m, MonadLoggerIO m) => Text -> Int -> (Pool SqlBackend -> m a) -> m a
- withSqlitePoolInfo :: (MonadUnliftIO m, MonadLoggerIO m) => SqliteConnectionInfo -> Int -> (Pool SqlBackend -> m a) -> m a
- withSqliteConn :: (MonadUnliftIO m, MonadLoggerIO m) => Text -> (SqlBackend -> m a) -> m a
- withSqliteConnInfo :: (MonadUnliftIO m, MonadLoggerIO m) => SqliteConnectionInfo -> (SqlBackend -> m a) -> m a
- createSqlitePool :: (MonadLoggerIO m, MonadUnliftIO m) => Text -> Int -> m (Pool SqlBackend)
- createSqlitePoolFromInfo :: (MonadLoggerIO m, MonadUnliftIO m) => SqliteConnectionInfo -> Int -> m (Pool SqlBackend)
- createSqlitePoolWithConfig :: (MonadUnliftIO m, MonadLoggerIO m) => Text -> ConnectionPoolConfig -> m (Pool SqlBackend)
- module Database.Persist.Sql
- data SqliteConf
  - = SqliteConf {
    - sqlDatabase :: Text
    - sqlPoolSize :: Int
    }
  - | SqliteConfInfo {
    - sqlConnInfo :: SqliteConnectionInfo
    - sqlPoolSize :: Int
    }
- data SqliteConnectionInfo
- mkSqliteConnectionInfo :: Text -> SqliteConnectionInfo
- sqlConnectionStr :: Lens' SqliteConnectionInfo Text
- walEnabled :: Lens' SqliteConnectionInfo Bool
- fkEnabled :: Lens' SqliteConnectionInfo Bool
- extraPragmas :: Lens' SqliteConnectionInfo [Text]
- runSqlite :: MonadUnliftIO m => Text -> ReaderT SqlBackend (NoLoggingT (ResourceT m)) a -> m a
- runSqliteInfo :: MonadUnliftIO m => SqliteConnectionInfo -> ReaderT SqlBackend (NoLoggingT (ResourceT m)) a -> m a
- wrapConnection :: Connection -> LogFunc -> IO SqlBackend
- wrapConnectionInfo :: SqliteConnectionInfo -> Connection -> LogFunc -> IO SqlBackend
- mockMigration :: Migration -> IO ()
- retryOnBusy :: (MonadUnliftIO m, MonadLoggerIO m) => m a -> m a
- waitForDatabase :: forall (m :: Type -> Type) backend. (MonadUnliftIO m, MonadLoggerIO m, BackendCompatible SqlBackend backend) => ReaderT backend m ()
- data ForeignKeyViolation = ForeignKeyViolation {
  - foreignKeyTable :: Text
  - foreignKeyColumn :: Text
  - foreignKeyRowId :: Int64
  }
- checkForeignKeys :: forall (m :: Type -> Type) env. (MonadResource m, MonadReader env m, BackendCompatible SqlBackend env) => ConduitM () ForeignKeyViolation m ()
- data RawSqlite backend
- openRawSqliteConn :: (MonadUnliftIO m, MonadLoggerIO m) => SqliteConnectionInfo -> m (RawSqlite SqlBackend)
- persistentBackend :: forall backend1 backend2 f. Functor f => (backend1 -> f backend2) -> RawSqlite backend1 -> f (RawSqlite backend2)
- rawSqliteConnection :: forall backend f. Functor f => (Connection -> f Connection) -> RawSqlite backend -> f (RawSqlite backend)
- withRawSqliteConnInfo :: (MonadUnliftIO m, MonadLoggerIO m) => SqliteConnectionInfo -> (RawSqlite SqlBackend -> m a) -> m a
- createRawSqlitePoolFromInfo :: (MonadLoggerIO m, MonadUnliftIO m) => SqliteConnectionInfo -> (RawSqlite SqlBackend -> m ()) -> Int -> m (Pool (RawSqlite SqlBackend))
- createRawSqlitePoolFromInfo_ :: (MonadLoggerIO m, MonadUnliftIO m) => SqliteConnectionInfo -> Int -> m (Pool (RawSqlite SqlBackend))
- withRawSqlitePoolInfo :: (MonadUnliftIO m, MonadLoggerIO m) => SqliteConnectionInfo -> (RawSqlite SqlBackend -> m ()) -> Int -> (Pool (RawSqlite SqlBackend) -> m a) -> m a
- withRawSqlitePoolInfo_ :: (MonadUnliftIO m, MonadLoggerIO m) => SqliteConnectionInfo -> Int -> (Pool (RawSqlite SqlBackend) -> m a) -> m a

# Documentation

withSqlitePool Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) |
=> Text |
-> Int | number of connections to open
-> (Pool SqlBackend -> m a) |
-> m a |

Run the given action with a connection pool.

Like `createSqlitePool`, this should not be used with `:memory:`.

withSqlitePoolInfo Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) |
=> SqliteConnectionInfo |
-> Int | number of connections to open
-> (Pool SqlBackend -> m a) |
-> m a |

Run the given action with a connection pool.

Like `createSqlitePool`, this should not be used with `:memory:`.

Since: 2.6.2

withSqliteConn :: (MonadUnliftIO m, MonadLoggerIO m) => Text -> (SqlBackend -> m a) -> m a Source #

withSqliteConnInfo :: (MonadUnliftIO m, MonadLoggerIO m) => SqliteConnectionInfo -> (SqlBackend -> m a) -> m a Source #

Since: 2.6.2

createSqlitePool :: (MonadLoggerIO m, MonadUnliftIO m) => Text -> Int -> m (Pool SqlBackend) Source #

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 :: (MonadLoggerIO m, MonadUnliftIO m) => SqliteConnectionInfo -> Int -> m (Pool SqlBackend) Source #

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

Since: 2.6.2

createSqlitePoolWithConfig Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) |
=> Text | connection string
-> ConnectionPoolConfig |
-> m (Pool SqlBackend) |

Create a pool of SQLite connections.

Since: 2.13.4.0

module Database.Persist.Sql

data SqliteConf Source #

Information required to setup a connection pool.

Constructors

SqliteConf |

Fields

- sqlDatabase :: Text
- sqlPoolSize :: Int

SqliteConfInfo |

Fields

- sqlConnInfo :: SqliteConnectionInfo
- sqlPoolSize :: Int

#### Instances

Instances details

FromJSON SqliteConf Source # |
Instance details Defined in Database.Persist.Sqlite Methods parseJSON :: Value -> Parser SqliteConf Source # parseJSONList :: Value -> Parser [SqliteConf] Source # omittedField :: Maybe SqliteConf Source #
Show SqliteConf Source # |
Instance details Defined in Database.Persist.Sqlite Methods showsPrec :: Int -> SqliteConf -> ShowS Source # show :: SqliteConf -> String Source # showList :: [SqliteConf] -> ShowS Source #
PersistConfig SqliteConf Source # |

Instance details

Defined in Database.Persist.Sqlite

Associated Types

type PersistConfigBackend SqliteConf |
Instance details Defined in Database.Persist.Sqlite type PersistConfigBackend SqliteConf = SqlPersistT
type PersistConfigPool SqliteConf |
Instance details Defined in Database.Persist.Sqlite type PersistConfigPool SqliteConf = ConnectionPool

Methods

loadConfig :: Value -> Parser SqliteConf Source #

applyEnv :: SqliteConf -> IO SqliteConf Source #

createPoolConfig :: SqliteConf -> IO (PersistConfigPool SqliteConf) Source #

runPool :: MonadUnliftIO m => SqliteConf -> PersistConfigBackend SqliteConf m a -> PersistConfigPool SqliteConf -> m a Source #

type PersistConfigBackend SqliteConf Source # |
Instance details Defined in Database.Persist.Sqlite type PersistConfigBackend SqliteConf = SqlPersistT
type PersistConfigPool SqliteConf Source # |
Instance details Defined in Database.Persist.Sqlite type PersistConfigPool SqliteConf = ConnectionPool

data SqliteConnectionInfo Source #

Information required to connect to a sqlite database. We export lenses instead of fields to avoid being limited to the current implementation.

Since: 2.6.2

#### Instances

Instances details

FromJSON SqliteConnectionInfo Source # |
Instance details Defined in Database.Persist.Sqlite Methods parseJSON :: Value -> Parser SqliteConnectionInfo Source # parseJSONList :: Value -> Parser [SqliteConnectionInfo] Source # omittedField :: Maybe SqliteConnectionInfo Source #
Show SqliteConnectionInfo Source # |
Instance details Defined in Database.Persist.Sqlite Methods showsPrec :: Int -> SqliteConnectionInfo -> ShowS Source # show :: SqliteConnectionInfo -> String Source # showList :: [SqliteConnectionInfo] -> ShowS Source #

mkSqliteConnectionInfo :: Text -> SqliteConnectionInfo Source #

Creates a SqliteConnectionInfo from a connection string, with the default settings.

Since: 2.6.2

sqlConnectionStr :: Lens' SqliteConnectionInfo Text Source #

walEnabled :: Lens' SqliteConnectionInfo Bool Source #

fkEnabled :: Lens' SqliteConnectionInfo Bool Source #

extraPragmas :: Lens' SqliteConnectionInfo [Text] Source #

runSqlite Source #

Arguments

:: MonadUnliftIO m |
=> Text | connection string
-> ReaderT SqlBackend (NoLoggingT (ResourceT m)) a | database action
-> 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.

Since: 1.1.4

runSqliteInfo Source #

Arguments

:: MonadUnliftIO m |
=> SqliteConnectionInfo |
-> ReaderT SqlBackend (NoLoggingT (ResourceT m)) a | database action
-> 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.

Since: 2.6.2

wrapConnection :: Connection -> LogFunc -> IO SqlBackend Source #

Wrap up a raw `Connection` as a Persistent SQL `Connection`.

### Example usage

Expand

    {-# LANGUAGE GADTs #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE MultiParamTypeClasses #-}
    {-# LANGUAGE TypeFamilies #-}
    {-# LANGUAGE TemplateHaskell #-}
    {-# LANGUAGE QuasiQuotes #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}

    import Control.Monad.IO.Class  (liftIO)
    import Database.Persist
    import Database.Sqlite
    import Database.Persist.Sqlite
    import Database.Persist.TH

    share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
    Person
      name String
      age Int Maybe
      deriving Show
    |]

    main :: IO ()
    main = do
      conn <- open "/home/sibi/test.db"
      (backend :: SqlBackend) <- wrapConnection conn (\_ _ _ _ -> return ())
      flip runSqlPersistM backend $ do
             runMigration migrateAll
             insert_ $ Person "John doe" $ Just 35
             insert_ $ Person "Hema" $ Just 36
             (pers :: [Entity Person]) <- selectList [] []
             liftIO $ print pers
      close' backend

On executing it, you get this output:

    Migrating: CREATE TABLE "person"("id" INTEGER PRIMARY KEY,"name" VARCHAR NOT NULL,"age" INTEGER NULL)
    [Entity {entityKey = PersonKey {unPersonKey = SqlBackendKey {unSqlBackendKey = 1}}, entityVal = Person {personName = "John doe", personAge = Just 35}},Entity {entityKey = PersonKey {unPersonKey = SqlBackendKey {unSqlBackendKey = 2}}, entityVal = Person {personName = "Hema", personAge = Just 36}}]

Since: 1.1.5

wrapConnectionInfo :: SqliteConnectionInfo -> Connection -> LogFunc -> IO SqlBackend Source #

Wrap up a raw `Connection` as a Persistent SQL `Connection`, allowing full control over WAL and FK constraints.

Since: 2.6.2

mockMigration :: Migration -> IO () Source #

Mock a migration even when the database is not present. This function performs the same functionality of `printMigration` with the difference that an actual database isn't needed for it.

retryOnBusy :: (MonadUnliftIO m, MonadLoggerIO m) => m a -> m a Source #

Retry if a Busy is thrown, following an exponential backoff strategy.

Since: 2.9.3

waitForDatabase :: forall (m :: Type -> Type) backend. (MonadUnliftIO m, MonadLoggerIO m, BackendCompatible SqlBackend backend) => ReaderT backend m () Source #

Wait until some noop action on the database does not return an `ErrorBusy`. See `retryOnBusy`.

Since: 2.9.3

data ForeignKeyViolation Source #

Data type for reporting foreign key violations using `checkForeignKeys`.

Since: 2.11.1

Constructors

ForeignKeyViolation |

Fields

- foreignKeyTable :: Text

  The table of the violated constraint

- foreignKeyColumn :: Text

  The column of the violated constraint

- foreignKeyRowId :: Int64

  The ROWID of the row with the violated foreign key constraint

#### Instances

Instances details

Show ForeignKeyViolation Source # |
Instance details Defined in Database.Persist.Sqlite Methods showsPrec :: Int -> ForeignKeyViolation -> ShowS Source # show :: ForeignKeyViolation -> String Source # showList :: [ForeignKeyViolation] -> ShowS Source #
Eq ForeignKeyViolation Source # |
Instance details Defined in Database.Persist.Sqlite Methods (==) :: ForeignKeyViolation -> ForeignKeyViolation -> Bool Source # (/=) :: ForeignKeyViolation -> ForeignKeyViolation -> Bool Source #
Ord ForeignKeyViolation Source # |

Instance details

Defined in Database.Persist.Sqlite

Methods

compare :: ForeignKeyViolation -> ForeignKeyViolation -> Ordering Source #

(<) :: ForeignKeyViolation -> ForeignKeyViolation -> Bool Source #

(<=) :: ForeignKeyViolation -> ForeignKeyViolation -> Bool Source #

(>) :: ForeignKeyViolation -> ForeignKeyViolation -> Bool Source #

(>=) :: ForeignKeyViolation -> ForeignKeyViolation -> Bool Source #

max :: ForeignKeyViolation -> ForeignKeyViolation -> ForeignKeyViolation Source #

min :: ForeignKeyViolation -> ForeignKeyViolation -> ForeignKeyViolation Source #

checkForeignKeys :: forall (m :: Type -> Type) env. (MonadResource m, MonadReader env m, BackendCompatible SqlBackend env) => ConduitM () ForeignKeyViolation m () Source #

Outputs all (if any) the violated foreign key constraints in the database.

The main use is to validate that no foreign key constraints were broken/corrupted by anyone operating on the database with foreign keys disabled. See `fkEnabled`.

Since: 2.11.1

data RawSqlite backend Source #

Wrapper for persistent SqlBackends that carry the corresponding `Connection`.

Since: 2.10.2

#### Instances

Instances details

BackendCompatible b (RawSqlite b) Source # |
Instance details Defined in Database.Persist.Sqlite Methods projectBackend :: RawSqlite b -> b Source #
(PersistCore b, PersistCore (RawSqlite b), FromJSON (BackendKey b)) => FromJSON (BackendKey (RawSqlite b)) Source # |
Instance details Defined in Database.Persist.Sqlite Methods parseJSON :: Value -> Parser (BackendKey (RawSqlite b)) Source # parseJSONList :: Value -> Parser [BackendKey (RawSqlite b)] Source # omittedField :: Maybe (BackendKey (RawSqlite b)) Source #
(PersistCore b, PersistCore (RawSqlite b), ToJSON (BackendKey b)) => ToJSON (BackendKey (RawSqlite b)) Source # |
Instance details Defined in Database.Persist.Sqlite Methods toJSON :: BackendKey (RawSqlite b) -> Value Source # toEncoding :: BackendKey (RawSqlite b) -> Encoding Source # toJSONList :: [BackendKey (RawSqlite b)] -> Value Source # toEncodingList :: [BackendKey (RawSqlite b)] -> Encoding Source # omitField :: BackendKey (RawSqlite b) -> Bool Source #
(PersistCore b, PersistCore (RawSqlite b), Bounded (BackendKey b)) => Bounded (BackendKey (RawSqlite b)) Source # |
Instance details Defined in Database.Persist.Sqlite Methods minBound :: BackendKey (RawSqlite b) Source # maxBound :: BackendKey (RawSqlite b) Source #
(PersistCore b, PersistCore (RawSqlite b), Enum (BackendKey b)) => Enum (BackendKey (RawSqlite b)) Source # |

Instance details

Defined in Database.Persist.Sqlite

Methods

succ :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

pred :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

toEnum :: Int -> BackendKey (RawSqlite b) Source #

fromEnum :: BackendKey (RawSqlite b) -> Int Source #

enumFrom :: BackendKey (RawSqlite b) -> [BackendKey (RawSqlite b)] Source #

enumFromThen :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> [BackendKey (RawSqlite b)] Source #

enumFromTo :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> [BackendKey (RawSqlite b)] Source #

enumFromThenTo :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> [BackendKey (RawSqlite b)] Source #

(PersistCore b, PersistCore (RawSqlite b), Num (BackendKey b)) => Num (BackendKey (RawSqlite b)) Source # |

Instance details

Defined in Database.Persist.Sqlite

Methods

(+) :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

(-) :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

(*) :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

negate :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

abs :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

signum :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

fromInteger :: Integer -> BackendKey (RawSqlite b) Source #

(PersistCore b, PersistCore (RawSqlite b), Read (BackendKey b)) => Read (BackendKey (RawSqlite b)) Source # |
Instance details Defined in Database.Persist.Sqlite Methods readsPrec :: Int -> ReadS (BackendKey (RawSqlite b)) Source # readList :: ReadS [BackendKey (RawSqlite b)] Source # readPrec :: ReadPrec (BackendKey (RawSqlite b)) Source # readListPrec :: ReadPrec [BackendKey (RawSqlite b)] Source #
(PersistCore b, PersistCore (RawSqlite b), Integral (BackendKey b)) => Integral (BackendKey (RawSqlite b)) Source # |

Instance details

Defined in Database.Persist.Sqlite

Methods

quot :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

rem :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

div :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

mod :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

quotRem :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> (BackendKey (RawSqlite b), BackendKey (RawSqlite b)) Source #

divMod :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> (BackendKey (RawSqlite b), BackendKey (RawSqlite b)) Source #

toInteger :: BackendKey (RawSqlite b) -> Integer Source #

(PersistCore b, PersistCore (RawSqlite b), Real (BackendKey b)) => Real (BackendKey (RawSqlite b)) Source # |
Instance details Defined in Database.Persist.Sqlite Methods toRational :: BackendKey (RawSqlite b) -> Rational Source #
(PersistCore b, PersistCore (RawSqlite b), Show (BackendKey b)) => Show (BackendKey (RawSqlite b)) Source # |
Instance details Defined in Database.Persist.Sqlite Methods showsPrec :: Int -> BackendKey (RawSqlite b) -> ShowS Source # show :: BackendKey (RawSqlite b) -> String Source # showList :: [BackendKey (RawSqlite b)] -> ShowS Source #
(PersistCore b, PersistCore (RawSqlite b), Eq (BackendKey b)) => Eq (BackendKey (RawSqlite b)) Source # |
Instance details Defined in Database.Persist.Sqlite Methods (==) :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> Bool Source # (/=) :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> Bool Source #
(PersistCore b, PersistCore (RawSqlite b), Ord (BackendKey b)) => Ord (BackendKey (RawSqlite b)) Source # |

Instance details

Defined in Database.Persist.Sqlite

Methods

compare :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> Ordering Source #

(<) :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> Bool Source #

(<=) :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> Bool Source #

(>) :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> Bool Source #

(>=) :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> Bool Source #

max :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

min :: BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) -> BackendKey (RawSqlite b) Source #

(PersistCore b, PersistCore (RawSqlite b), PersistField (BackendKey b)) => PersistField (BackendKey (RawSqlite b)) Source # |
Instance details Defined in Database.Persist.Sqlite Methods toPersistValue :: BackendKey (RawSqlite b) -> PersistValue Source # fromPersistValue :: PersistValue -> Either Text (BackendKey (RawSqlite b)) Source #
(HasPersistBackend b, PersistQueryRead b) => PersistQueryRead (RawSqlite b) Source # |

Instance details

Defined in Database.Persist.Sqlite

Methods

selectSourceRes :: forall record (m1 :: Type -> Type) (m2 :: Type -> Type). (PersistRecordBackend record (RawSqlite b), MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT (RawSqlite b) m1 (Acquire (ConduitM () (Entity record) m2 ())) Source #

selectFirst :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record (RawSqlite b)) => [Filter record] -> [SelectOpt record] -> ReaderT (RawSqlite b) m (Maybe (Entity record)) Source #

selectKeysRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) record. (MonadIO m1, MonadIO m2, PersistRecordBackend record (RawSqlite b)) => [Filter record] -> [SelectOpt record] -> ReaderT (RawSqlite b) m1 (Acquire (ConduitM () (Key record) m2 ())) Source #

count :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record (RawSqlite b)) => [Filter record] -> ReaderT (RawSqlite b) m Int Source #

exists :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record (RawSqlite b)) => [Filter record] -> ReaderT (RawSqlite b) m Bool Source #

(HasPersistBackend b, PersistQueryWrite b) => PersistQueryWrite (RawSqlite b) Source # |

Instance details

Defined in Database.Persist.Sqlite

Methods

updateWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record (RawSqlite b)) => [Filter record] -> [Update record] -> ReaderT (RawSqlite b) m () Source #

deleteWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record (RawSqlite b)) => [Filter record] -> ReaderT (RawSqlite b) m () Source #

HasPersistBackend b => HasPersistBackend (RawSqlite b) Source # |

Instance details

Defined in Database.Persist.Sqlite

Associated Types

type BaseBackend (RawSqlite b0) |
Instance details Defined in Database.Persist.Sqlite type BaseBackend (RawSqlite b0) = BaseBackend (Compatible b0 (RawSqlite b0))

Methods

persistBackend :: RawSqlite b -> BaseBackend (RawSqlite b) Source #

PersistCore b => PersistCore (RawSqlite b) Source # |

Instance details

Defined in Database.Persist.Sqlite

Associated Types

newtype BackendKey (RawSqlite b) |

Instance details

Defined in Database.Persist.Sqlite

newtype BackendKey (RawSqlite b) = RawSqliteKey {

- unRawSqliteKey :: BackendKey (Compatible b (RawSqlite b))

}

(HasPersistBackend b, PersistStoreRead b) => PersistStoreRead (RawSqlite b) Source # |
Instance details Defined in Database.Persist.Sqlite Methods get :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => Key record -> ReaderT (RawSqlite b) m (Maybe record) Source # getMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => [Key record] -> ReaderT (RawSqlite b) m (Map (Key record) record) Source #
(HasPersistBackend b, PersistStoreWrite b) => PersistStoreWrite (RawSqlite b) Source # |

Instance details

Defined in Database.Persist.Sqlite

Methods

insert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b), SafeToInsert record) => record -> ReaderT (RawSqlite b) m (Key record) Source #

insert_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b), SafeToInsert record) => record -> ReaderT (RawSqlite b) m () Source #

insertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b), SafeToInsert record) => [record] -> ReaderT (RawSqlite b) m [Key record] Source #

insertMany_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b), SafeToInsert record) => [record] -> ReaderT (RawSqlite b) m () Source #

insertEntityMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => [Entity record] -> ReaderT (RawSqlite b) m () Source #

insertKey :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => Key record -> record -> ReaderT (RawSqlite b) m () Source #

repsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => Key record -> record -> ReaderT (RawSqlite b) m () Source #

repsertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => [(Key record, record)] -> ReaderT (RawSqlite b) m () Source #

replace :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => Key record -> record -> ReaderT (RawSqlite b) m () Source #

delete :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => Key record -> ReaderT (RawSqlite b) m () Source #

update :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => Key record -> [Update record] -> ReaderT (RawSqlite b) m () Source #

updateGet :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => Key record -> [Update record] -> ReaderT (RawSqlite b) m record Source #

(HasPersistBackend b, PersistUniqueRead b) => PersistUniqueRead (RawSqlite b) Source # |
Instance details Defined in Database.Persist.Sqlite Methods getBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => Unique record -> ReaderT (RawSqlite b) m (Maybe (Entity record)) Source # existsBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => Unique record -> ReaderT (RawSqlite b) m Bool Source #
(HasPersistBackend b, PersistUniqueWrite b) => PersistUniqueWrite (RawSqlite b) Source # |

Instance details

Defined in Database.Persist.Sqlite

Methods

deleteBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b)) => Unique record -> ReaderT (RawSqlite b) m () Source #

insertUnique :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b), SafeToInsert record) => record -> ReaderT (RawSqlite b) m (Maybe (Key record)) Source #

insertUnique_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b), SafeToInsert record) => record -> ReaderT (RawSqlite b) m (Maybe ()) Source #

upsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b), OnlyOneUniqueKey record, SafeToInsert record) => record -> [Update record] -> ReaderT (RawSqlite b) m (Entity record) Source #

upsertBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b), SafeToInsert record) => Unique record -> record -> [Update record] -> ReaderT (RawSqlite b) m (Entity record) Source #

putMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawSqlite b), SafeToInsert record) => [record] -> ReaderT (RawSqlite b) m () Source #

(PersistCore b, PersistCore (RawSqlite b), PersistFieldSql (BackendKey b)) => PersistFieldSql (BackendKey (RawSqlite b)) Source # |
Instance details Defined in Database.Persist.Sqlite Methods sqlType :: Proxy (BackendKey (RawSqlite b)) -> SqlType Source #
newtype BackendKey (RawSqlite b) Source # |

Instance details

Defined in Database.Persist.Sqlite

newtype BackendKey (RawSqlite b) = RawSqliteKey {

- unRawSqliteKey :: BackendKey (Compatible b (RawSqlite b))

}

type BaseBackend (RawSqlite b0) Source # |
Instance details Defined in Database.Persist.Sqlite type BaseBackend (RawSqlite b0) = BaseBackend (Compatible b0 (RawSqlite b0))

openRawSqliteConn :: (MonadUnliftIO m, MonadLoggerIO m) => SqliteConnectionInfo -> m (RawSqlite SqlBackend) Source #

Open a ``RawSqlite` `SqlBackend`` connection from a `SqliteConnectionInfo`.

When using this function, the caller has to accept the responsibility of cleaning up the resulting connection. To do this, use `close` with the `rawSqliteConnection` - it's enough to simply drop the `persistBackend` afterwards.

Since: 2.13.2

persistentBackend :: forall backend1 backend2 f. Functor f => (backend1 -> f backend2) -> RawSqlite backend1 -> f (RawSqlite backend2) Source #

rawSqliteConnection :: forall backend f. Functor f => (Connection -> f Connection) -> RawSqlite backend -> f (RawSqlite backend) Source #

withRawSqliteConnInfo :: (MonadUnliftIO m, MonadLoggerIO m) => SqliteConnectionInfo -> (RawSqlite SqlBackend -> m a) -> m a Source #

Like `withSqliteConnInfo`, but exposes the internal `Connection`. For power users who want to manually interact with SQLite's C API via internals exposed by Database.Sqlite.Internal

Since: 2.10.2

createRawSqlitePoolFromInfo Source #

Arguments

:: (MonadLoggerIO m, MonadUnliftIO m) |
=> SqliteConnectionInfo |
-> (RawSqlite SqlBackend -> m ()) | An action that is run whenever a new `RawSqlite` connection is allocated in the pool. The main use of this function is to register custom functions with the SQLite connection upon creation.
-> Int |
-> m (Pool (RawSqlite SqlBackend)) |

Like `createSqlitePoolFromInfo`, but like `withRawSqliteConnInfo` it exposes the internal `Connection`.

For power users who want to manually interact with SQLite's C API via internals exposed by Database.Sqlite.Internal. The callback can be used to run arbitrary actions on the connection upon allocation from the pool.

Since: 2.10.6

createRawSqlitePoolFromInfo_ :: (MonadLoggerIO m, MonadUnliftIO m) => SqliteConnectionInfo -> Int -> m (Pool (RawSqlite SqlBackend)) Source #

Like `createRawSqlitePoolFromInfo`, but doesn't require a callback operating on the connection.

Since: 2.10.6

withRawSqlitePoolInfo Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) |
=> SqliteConnectionInfo |
-> (RawSqlite SqlBackend -> m ()) |
-> Int | number of connections to open
-> (Pool (RawSqlite SqlBackend) -> m a) |
-> m a |

Like `createSqlitePoolInfo`, but based on `createRawSqlitePoolFromInfo`.

Since: 2.10.6

withRawSqlitePoolInfo_ Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) |
=> SqliteConnectionInfo |
-> Int | number of connections to open
-> (Pool (RawSqlite SqlBackend) -> m a) |
-> m a |

Like `createSqlitePoolInfo`, but based on `createRawSqlitePoolFromInfo_`.

Since: 2.10.6