| Copyright | 2015 Dylan Simon |
|---|---|
| Safe Haskell | None |
| Language | Haskell98 |
Database.PostgreSQL.Typed.TH
Description
Support functions for compile-time PostgreSQL connection and state management. You can use these to build your own Template Haskell functions using the PostgreSQL connection.
- getTPGDatabase :: IO PGDatabase
- withTPGTypeConnection :: (PGTypeConnection -> IO a) -> IO a
- withTPGConnection :: (PGConnection -> IO a) -> IO a
- useTPGDatabase :: PGDatabase -> DecsQ
- reloadTPGTypes :: DecsQ
- data TPGValueInfo = TPGValueInfo {}
- tpgDescribe :: ByteString -> [String] -> Bool -> IO ([TPGValueInfo], [TPGValueInfo])
- tpgTypeEncoder :: Bool -> TPGValueInfo -> Name -> Exp
- tpgTypeDecoder :: Bool -> TPGValueInfo -> Name -> Exp
- tpgTypeBinary :: TPGValueInfo -> Name -> Exp
Documentation
getTPGDatabase :: IO PGDatabase Source #
Generate a PGDatabase based on the environment variables:
TPG_HOST (localhost); TPG_SOCK or TPG_PORT (5432); TPG_DB or user; TPG_USER or USER (postgres); TPG_PASS ()
withTPGTypeConnection :: (PGTypeConnection -> IO a) -> IO a Source #
Run an action using the Template Haskell state.
withTPGConnection :: (PGConnection -> IO a) -> IO a Source #
Run an action using the Template Haskell PostgreSQL connection.
useTPGDatabase :: PGDatabase -> DecsQ Source #
Specify an alternative database to use during compilation.
This lets you override the default connection parameters that are based on TPG environment variables.
This should be called as a top-level declaration and produces no code.
It uses pgReconnect so is safe to call multiple times with the same database.
reloadTPGTypes :: DecsQ Source #
Force reloading of all types from the database. This may be needed if you make structural changes to the database during compile-time.
data TPGValueInfo Source #
Constructors
| TPGValueInfo | |
Fields
| |
tpgDescribe :: ByteString -> [String] -> Bool -> IO ([TPGValueInfo], [TPGValueInfo]) Source #
A type-aware wrapper to pgDescribe
tpgTypeEncoder :: Bool -> TPGValueInfo -> Name -> Exp Source #
TH expression to encode a PGParameter value to a Maybe ByteString.
tpgTypeDecoder :: Bool -> TPGValueInfo -> Name -> Exp Source #
TH expression to decode a Maybe ByteString to a (Maybe) PGColumn value.
tpgTypeBinary :: TPGValueInfo -> Name -> Exp Source #
TH expression calling pgBinaryColumn.