Safe Haskell | None |
---|---|
Language | Haskell2010 |
PostgreSQL backend for Selda.
Synopsis
- data PG
- data PGConnectInfo = PGConnectInfo {
- pgHost :: Text
- pgPort :: Int
- pgDatabase :: Text
- pgSchema :: Maybe Text
- pgUsername :: Maybe Text
- pgPassword :: Maybe Text
- withPostgreSQL :: (MonadIO m, MonadMask m) => PGConnectInfo -> SeldaT PG m a -> m a
- on :: Text -> Text -> PGConnectInfo
- auth :: PGConnectInfo -> (Text, Text) -> PGConnectInfo
- pgOpen :: (MonadIO m, MonadMask m) => PGConnectInfo -> m (SeldaConnection PG)
- pgOpen' :: (MonadIO m, MonadMask m) => Maybe Text -> ByteString -> m (SeldaConnection PG)
- seldaClose :: MonadIO m => SeldaConnection b -> m ()
- pgConnString :: PGConnectInfo -> ByteString
- pgPPConfig :: PPConfig
Documentation
data PGConnectInfo Source #
PostgreSQL connection information.
PGConnectInfo | |
|
withPostgreSQL :: (MonadIO m, MonadMask m) => PGConnectInfo -> SeldaT PG m a -> m a Source #
Perform the given computation over a PostgreSQL database. The database connection is guaranteed to be closed when the computation terminates.
on :: Text -> Text -> PGConnectInfo infixl 7 Source #
Connect to the given database on the given host, on the default PostgreSQL port (5432):
withPostgreSQL ("my_db" `on` "example.com") $ do ...
auth :: PGConnectInfo -> (Text, Text) -> PGConnectInfo infixl 4 Source #
Add the given username and password to the given connection information:
withPostgreSQL ("my_db" `on` "example.com" `auth` ("user", "pass")) $ do ...
For more precise control over the connection options, you should modify
the PGConnectInfo
directly.
pgOpen :: (MonadIO m, MonadMask m) => PGConnectInfo -> m (SeldaConnection PG) Source #
Open a new PostgreSQL connection. The connection will persist across
calls to runSeldaT
, and must be explicitly closed using seldaClose
when no longer needed.
pgOpen' :: (MonadIO m, MonadMask m) => Maybe Text -> ByteString -> m (SeldaConnection PG) Source #
seldaClose :: MonadIO m => SeldaConnection b -> m () #
Close a reusable Selda connection.
Closing a connection while in use is undefined.
Passing a closed connection to runSeldaT
results in a SeldaError
being thrown. Closing a connection more than once is a no-op.
pgConnString :: PGConnectInfo -> ByteString Source #
Convert PGConnectInfo
into ByteString