postgresql-typed-0.4.5: A PostgreSQL library with compile-time SQL type inference and optional HDBC backend

Copyright2015 Dylan Simon
Safe HaskellNone
LanguageHaskell98

Database.PostgreSQL.Typed.TH

Contents

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 ()

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.

HDBC support

type PGTypes = IntMap TPGType Source #

Map keyed on fromIntegral OID.

pgLoadTypes :: PGConnection -> IO PGTypes Source #

Load a map of types from the database.