pipes-postgresql-simple-0.1.3.0: Convert various postgresql-simple calls to work with pipes

Safe HaskellNone
LanguageHaskell98

Pipes.PostgreSQL.Simple

Contents

Description

Pipes utilities built on top of postgresql-simple

Synopsis

Querying

query :: (MonadIO m, FromRow r, ToRow params) => Connection -> Query -> params -> Producer r m () Source #

Convert a query to a Producer of rows.

For example,

pg <- connectToPostgresql
query pg "SELECT * FROM widgets WHERE ID = ?" (Only widgetId) >-> print

Will select all widgets for a given widgetId, and then print each row to standard output.

query_ :: (MonadIO m, FromRow r) => Connection -> Query -> Producer r m () Source #

Like query, but it doesn't perform any query parameter substitution.

Serialization and Deserialization

data Format Source #

The PostgreSQL file format, used by the COPY command

Constructors

Text 
Binary 
CSV 

Instances

fromTable :: MonadIO m => Connection -> Format -> String -> Producer ByteString m Int64 Source #

Convert a table to a byte stream. This is equivilent to a PostgreSQL COPY ... TO statement.

Returns the number of rows processed.

toTable :: (MonadCatch m, MonadIO m) => Connection -> Format -> String -> Producer ByteString m () -> m Int64 Source #

Convert a byte stream to a table. This is equivilent to a PostgreSQL COPY ... FROM statement.

Returns the number of rows processed