Safe Haskell | None |
---|
Pipes utilities built on top of postgresql-simple
- query :: (MonadIO m, FromRow r, ToRow params) => Connection -> Query -> params -> Producer r m ()
- query_ :: (MonadIO m, FromRow r) => Connection -> Query -> Producer r m ()
- data Format
- fromTable :: MonadIO m => Connection -> Format -> String -> Producer ByteString m Int64
- toTable :: (MonadCatch m, MonadIO m) => Connection -> Format -> String -> Producer ByteString m () -> m Int64
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
fromTable :: MonadIO m => Connection -> Format -> String -> Producer ByteString m Int64Source
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 Int64Source
Convert a byte stream to a table. This is equivilent to a PostgreSQL
COPY ... FROM
statement.
Returns the number of rows processed