Skip to main content

execute_stream_with_params

Function execute_stream_with_params 

Source
pub fn execute_stream_with_params(
    query: &str,
    query_args: Option<&[Arg<'_>]>,
    params: impl Into<QueryParams>,
) -> Result<QueryStream<'static>>
Expand description

Execute a one-off query with ClickHouse {name:Type} parameter binding and stream text chunks.

Counterpart to execute_stream. Syntax errors fail when the stream is created. A missing placeholder binding is reported on the first QueryStream::next_chunk, not at start.

§Examples

use chdb_rust::arg::Arg;
use chdb_rust::execute_stream_with_params;
use chdb_rust::format::OutputFormat;

let mut stream = execute_stream_with_params(
    "SELECT {x:UInt64} AS v",
    Some(&[Arg::OutputFormat(OutputFormat::CSV)]),
    [("x", 11_u64)],
)?;
while let Some(chunk) = stream.next_chunk()? {
    print!("{}", chunk.data_utf8_lossy());
}

§Errors

This function will return an error if:

  • The query syntax is invalid
  • The connection cannot be established
  • The query cannot be started
  • A connection is already open on a data path. See Error::PathConflict.