Skip to main content

Crate snowflake_connector_rs

Crate snowflake_connector_rs 

Source
Expand description

§Snowflake Connector

A Rust client for Snowflake.

let client = Client::new(ClientConfig::new(
    "USERNAME",
    "ACCOUNT",
    AuthConfig::password("PASSWORD"),
))?;
let session = client.create_session().await?;

// Collect dynamic or typed rows in one shot.
let dynamic_rows = session
    .query("SELECT 1 AS id, 'hi' AS name")
    .await?
    .collect::<Vec<_>>()
    .await?;
assert_eq!(dynamic_rows.len(), 1);

let typed_rows = session
    .query_as("SELECT 1 AS id, 'hi' AS name")
    .await?
    .collect::<Vec<(i64, String)>>()
    .await?;
assert_eq!(typed_rows, vec![(1, "hi".to_string())]);

// Collect materialized storage as a ResultTable or TypedResultTable.
let table = session
    .query("SELECT 1 AS id")
    .await?
    .collect_table()
    .await?;
assert_eq!(table.row_count(), 1);

let typed_table = session
    .query_as::<(i64,), _>("SELECT 1 AS id")
    .await?
    .collect_table()
    .await?;
assert_eq!(typed_table.row_count(), 1);

// Or stream typed partitions for large results.
let mut result = session
    .query_as::<(i64, String), _>("SELECT 1 AS id, 'hi' AS name")
    .await?;
while let Some(table) = result.next_table().await? {
    for row in table.rows() {
        let (id, name) = row?;
        println!("{id} {name}");
    }
}

// Keep the untyped streaming path when you only need materialized storage.
let result = session.query("SELECT 1 AS id").await?;
assert_eq!(result.schema().len(), 1);

Re-exports§

pub use decode::CellPlan;
pub use decode::CellPlanContext;
pub use decode::FromCell;
pub use decode::FromRow;
pub use decode::RowPlanContext;
pub use error::Error;
pub use error::ErrorKind;
pub use error::Result;

Modules§

bind
Types passed to Statement::bind and Statement::bind_named.
decode
Traits and helpers for decoding query results into Rust types.
error

Structs§

AuthConfig
BinaryValue
Result-side representation of a Snowflake BINARY cell.
CellRef
Borrowed view of a single cell.
Client
ClientConfig
Top-level configuration for a Client.
CollectOptions
Options for controlling how result-set collection fetches remaining partitions.
Column
Metadata for a single result-set column.
DecimalValue
Result-side representation of a Snowflake NUMBER / DECIMAL cell with non-zero scale.
DynamicRow
A row decoded into the dynamic CellValue vocabulary.
ExternalBrowserConfig
Configuration for AuthConfig::external_browser.
KeyPairConfig
NamedBinds
Typestate marker for a Statement using named (:name / :1) binds.
PasswordConfig
Password authentication, optionally carrying an MFA passcode.
PositionalBinds
Typestate marker for a Statement using positional (?) binds.
ProxyConfig
Configuration for an HTTP proxy used by TransportConfig.
QueryCanceller
A cloneable controller that cancels the query of the QueryHandle it was obtained from.
QueryConfig
Client-side query execution policy.
QueryHandle
An owned statement execution that can be explicitly cancelled through a QueryCanceller.
QueryOptions
Per-query overrides for a single Session::query_with_options / Session::query_as_with_options / Session::query_handle_with_options call.
ResultCursor
A query result as a cursor over its remaining partitions.
ResultTable
Fully materialized rows with a shared schema and query id.
RowRef
Borrowed view of a single row.
Rows
Typed iterator over result rows.
Schema
Ordered metadata describing the columns of a result set.
Session
SessionConfig
Server-side session context sent to Snowflake at login time.
Statement
Builder for a SQL statement and its bind values, accepted by Session::query / Session::query_as.
TransportConfig
HTTP transport-layer options.
TypedResultCursor
Typed wrapper over a ResultCursor that owns a precomputed decode plan.
TypedResultTable
A ResultTable paired with a pre-built decode plan for row type T.
UnboundBinds
Typestate marker for a Statement with no binds attached yet.

Enums§

BrowserLaunchMode
Controls how the SSO URL is opened.
CellValue
Decoded value of a single cell on the dynamic-typing path.
ColumnType
Snowflake column type as reported by the result-set metadata.
EndpointConfig
Endpoint resolution strategy for the Snowflake API base URL.
QueryCancelStatus
What a successful QueryCanceller::cancel call achieved.
VectorValue
Decoded Snowflake VECTOR value on the dynamic-typing path.

Traits§

IntoStatement
Marker trait for values accepted by Session::query / Session::query_as.

Derive Macros§

FromRow
Derives snowflake_connector_rs::FromRow for a struct.