Struct light_snowflake_connector::Statement
source · pub struct Statement { /* private fields */ }
Expand description
A builder for a prepared statement (created by SnowflakeClient)
Implementations§
source§impl Statement
impl Statement
sourcepub fn new(sql: &str, config: &SnowflakeClient) -> Statement
pub fn new(sql: &str, config: &SnowflakeClient) -> Statement
Create a new statement from a SQL string and a SnowflakeClient
Usually you will want to use SnowflakeClient::prepare
instead of this method
but the difference is merely ergonomic.
sourcepub async fn query(&self) -> Result<QueryResponse, SnowflakeError>
pub async fn query(&self) -> Result<QueryResponse, SnowflakeError>
Execute SQL that returns a result set
This supports multiple partitions, which are streamed lazily but the first partition is buffered immediately.
For a single partition, consider using QueryResponse::only_partition
.
sourcepub async fn manipulate(&self) -> Result<Changes, SnowflakeError>
pub async fn manipulate(&self) -> Result<Changes, SnowflakeError>
Execute SQL that does not return a result set
This is useful for DML statements like INSERT
, UPDATE
, and DELETE
sourcepub fn with_timeout(self, timeout_seconds: u64) -> Statement
pub fn with_timeout(self, timeout_seconds: u64) -> Statement
Set the Snowflake-side timeout for the statement
The client-side timeout will automatically be set to this value plus 15 seconds
The default server side timeout is 172800 seconds (2 days), which is far too long for the use cases this library is targeting, so this library defaults to 30 seconds on the server side if not specified, implying a client-side timeout of 45 seconds.
sourcepub fn add_binding<T: Into<Binding>>(self, value: T) -> Statement
pub fn add_binding<T: Into<Binding>>(self, value: T) -> Statement
Add a binding to the statement
Several types are supported:
- All integers are converted to
i128
and bound asNUMBER
f64
andf32
are bound asREAL
bool
,&str
,String
,chrono::NaiveDate
,chrono::NaiveDateTime
, andchrono::NaiveTime
are bound asTEXT
More types may be supported in the future.
Text is the most flexible type, and for additional types you can usually workaround by converting to text before binding. Or, you could contribute to this library and add support