@hackage / valiant-streaming

Streaming adapter for valiant (streaming library)

Latest0.1.0.0

About

Metadata

  • Last updated , by joshburgess
  • License BSD-3-Clause
  • Categories Databases
  • Maintained by: joshburgess.webdev@gmail.com

  • Lottery factor: 1

Links

Installation

Tested Compilers

  1. 9.10.3

Package Flags

Use the -f option with cabal commands to enable flags

    werror (off by default)

    Enable -Werror for development builds.

Readme

valiant-streaming

streaming adapter for valiant.

Produces Stream (Of r) IO () values from query results.

Quick start

import Valiant
import Valiant.Stream
import Streaming.Prelude qualified as S

countUsers :: Pool -> IO Int
countUsers pool =
  withTransaction pool $ \tx ->
    S.length_ $ selectStream (txConn tx) listAllUsers () 500

Two streaming strategies

  • selectStream conn stmt params batchSize — cursor-based. Must run inside a transaction.
  • foldStream conn stmt params — single-shot extended-protocol query. No transaction required.

Both functions accumulate one result set at a time before yielding. For truly incremental memory use, drive Valiant.withCursor / Valiant.fetchBatch directly.

See the valiant tutorial for Statement definitions and the valiant prepare workflow.