pub fn execute_stream(
query: &str,
query_args: Option<&[Arg<'_>]>,
) -> Result<QueryStream<'static>>Expand description
Execute a one-off streaming query using an in-memory connection.
This function creates a temporary in-memory database connection, starts a
streaming query, and returns a QueryStream that owns the connection.
The connection is kept alive until the stream is dropped.
Primarily useful for reading external data: CSV files, S3, Parquet, etc.
§Arguments
query- The SQL query string to executequery_args- Optional array of query arguments (e.g., output format)
§Returns
Returns a QueryStream that owns the temporary connection, or an
Error if the query cannot be started.
§Examples
use chdb_rust::execute_stream;
use chdb_rust::arg::Arg;
use chdb_rust::format::OutputFormat;
let mut stream = execute_stream(
"SELECT number FROM numbers(100_000)",
Some(&[Arg::OutputFormat(OutputFormat::JSONEachRow)]),
)?;
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 execution fails