| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Database.PostgreSQL.Typed.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.
- data PGDatabase = PGDatabase {}
- defaultPGDatabase :: PGDatabase
- data PGConnection
- data PGError = PGError MessageFields
- pgMessageCode :: MessageFields -> String
- pgTypeEnv :: PGConnection -> PGTypeEnv
- pgConnect :: PGDatabase -> IO PGConnection
- pgDisconnect :: PGConnection -> IO ()
- pgReconnect :: PGConnection -> PGDatabase -> IO PGConnection
- pgDescribe :: PGConnection -> String -> [OID] -> Bool -> IO ([OID], [(String, OID, Bool)])
- pgSimpleQuery :: PGConnection -> String -> IO (Int, Seq PGValues)
- pgPreparedQuery :: PGConnection -> String -> [OID] -> PGValues -> [Bool] -> IO (Int, Seq PGValues)
- pgPreparedLazyQuery :: PGConnection -> String -> [OID] -> PGValues -> [Bool] -> Word32 -> IO [PGValues]
- pgCloseStatement :: PGConnection -> String -> [OID] -> IO ()
Documentation
data PGDatabase Source
Information for how to connect to a database, to be passed to pgConnect.
Constructors
| PGDatabase | |
Fields
| |
Instances
defaultPGDatabase :: PGDatabase Source
A database connection with sane defaults: localhost:5432:postgres
data PGConnection Source
An established connection to the PostgreSQL server. These objects are not thread-safe and must only be used for a single request at a time.
PGException is thrown upon encountering an ErrorResponse with severity of
ERROR, FATAL, or PANIC. It holds the message of the error.
Constructors
| PGError MessageFields |
pgMessageCode :: MessageFields -> String Source
Message SQLState code. See http://www.postgresql.org/docs/current/static/errcodes-appendix.html.
pgTypeEnv :: PGConnection -> PGTypeEnv Source
pgConnect :: PGDatabase -> IO PGConnection Source
Connect to a PostgreSQL server.
Arguments
| :: PGConnection | a handle from |
| -> IO () |
Disconnect cleanly from the PostgreSQL server.
pgReconnect :: PGConnection -> PGDatabase -> IO PGConnection Source
Possibly re-open a connection to a different database, either reusing the connection if the given database is already connected or closing it and opening a new one. Regardless, the input connection must not be used afterwards.
Arguments
| :: PGConnection | |
| -> String | SQL string |
| -> [OID] | Optional type specifications |
| -> Bool | Guess nullability, otherwise assume everything is |
| -> IO ([OID], [(String, OID, 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).
Arguments
| :: PGConnection | |
| -> String | SQL string |
| -> IO (Int, Seq PGValues) | The number of rows affected and a list of result rows |
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).
Arguments
| :: PGConnection | |
| -> String | SQL statement with placeholders |
| -> [OID] | Optional type specifications (only used for first call) |
| -> PGValues | Paremeters to bind to placeholders |
| -> [Bool] | Requested binary format for result columns |
| -> IO (Int, Seq PGValues) |
Prepare a statement, bind it, and execute it. If the given statement has already been prepared (and not yet closed) on this connection, it will be re-used.
Arguments
| :: PGConnection | |
| -> String | |
| -> [OID] | |
| -> PGValues | |
| -> [Bool] | |
| -> Word32 | Chunk size (1 is common, 0 is all-at-once) |
| -> IO [PGValues] |
Like pgPreparedQuery but requests results lazily in chunks of the given size.
Does not use a named portal, so other requests may not intervene.
pgCloseStatement :: PGConnection -> String -> [OID] -> IO () Source
Close a previously prepared query (if necessary).