templatepg-0.1.0: A PostgreSQL access library with compile-time SQL type inference

Database.TemplatePG.Protocol

Description

The Protocol module allows for direct, low-level communication with a PostgreSQL server over TCP/IP. You probably don't want to use this module directly.

Synopsis

Documentation

data PGException Source

PGException is thrown upon encountering an ErrorResponse with severity of ERROR, FATAL, or PANIC. It holds the SQLSTATE and message of the error.

Constructors

PGException String String 

pgConnectSource

Arguments

:: HostName

the host to connect to

-> PortID

the port to connect on

-> String

the database to connect to

-> String

the username to connect as

-> String

the password to connect with

-> IO Handle

a handle to communicate with the PostgreSQL server on

Connect to a PostgreSQL server.

pgDisconnectSource

Arguments

:: Handle

a handle from pgConnect

-> IO () 

Disconnect from a PostgreSQL server. Note that this currently doesn't send a close message.

describeStatementSource

Arguments

:: Handle 
-> String

SQL string

-> IO ([PGType], [(String, PGType, Bool)])

a list of parameter types, and a list of result field names, types, and nullability indicators.

Describe a SQL statement/query. A statement description consists of 0 or more parameter descriptions (a PostgreSQL type) and zero or more result field descriptions (for queries) (consist of the name of the field, the type of the field, and a nullability indicator).

executeSimpleQuerySource

Arguments

:: Handle 
-> String

SQL string

-> IO [[Maybe ByteString]]

A list of result rows, which themselves are a list of fields.

A simple query is one which requires sending only a single SimpleQuery message to the PostgreSQL server. The query is sent as a single string; you cannot bind parameters. Note that queries can return 0 results (an empty list).

executeSimpleStatementSource

Arguments

:: Handle 
-> String

SQL string

-> IO () 

While not strictly necessary, this can make code a little bit clearer. It executes a SimpleQuery but doesn't look for results.