postgresql-typed-0.6.2.2: PostgreSQL interface with compile-time SQL type checking, optional HDBC backend
Copyright2015 Dylan Simon
Safe HaskellSafe-Inferred
LanguageHaskell2010

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.

Synopsis

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.

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.