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::bindandStatement::bind_named. - decode
- Traits and helpers for decoding query results into Rust types.
- error
Structs§
- Auth
Config - Binary
Value - Result-side representation of a Snowflake
BINARYcell. - CellRef
- Borrowed view of a single cell.
- Client
- Client
Config - Top-level configuration for a
Client. - Collect
Options - Options for controlling how result-set collection fetches remaining partitions.
- Column
- Metadata for a single result-set column.
- Decimal
Value - Result-side representation of a Snowflake
NUMBER/DECIMALcell with non-zero scale. - Dynamic
Row - A row decoded into the dynamic
CellValuevocabulary. - External
Browser Config - Configuration for
AuthConfig::external_browser. - KeyPair
Config - Named
Binds - Typestate marker for a
Statementusing named (:name/:1) binds. - Password
Config - Password authentication, optionally carrying an MFA passcode.
- Positional
Binds - Typestate marker for a
Statementusing positional (?) binds. - Proxy
Config - Configuration for an HTTP proxy used by
TransportConfig. - Query
Canceller - A cloneable controller that cancels the query of the
QueryHandleit was obtained from. - Query
Config - Client-side query execution policy.
- Query
Handle - An owned statement execution that can be explicitly cancelled through a
QueryCanceller. - Query
Options - Per-query overrides for a single
Session::query_with_options/Session::query_as_with_options/Session::query_handle_with_optionscall. - Result
Cursor - A query result as a cursor over its remaining partitions.
- Result
Table - 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
- Session
Config - 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. - Transport
Config - HTTP transport-layer options.
- Typed
Result Cursor - Typed wrapper over a
ResultCursorthat owns a precomputed decode plan. - Typed
Result Table - A
ResultTablepaired with a pre-built decode plan for row typeT. - Unbound
Binds - Typestate marker for a
Statementwith no binds attached yet.
Enums§
- Browser
Launch Mode - Controls how the SSO URL is opened.
- Cell
Value - Decoded value of a single cell on the dynamic-typing path.
- Column
Type - Snowflake column type as reported by the result-set metadata.
- Endpoint
Config - Endpoint resolution strategy for the Snowflake API base URL.
- Query
Cancel Status - What a successful
QueryCanceller::cancelcall achieved. - Vector
Value - Decoded Snowflake
VECTORvalue on the dynamic-typing path.
Traits§
- Into
Statement - Marker trait for values accepted by
Session::query/Session::query_as.
Derive Macros§
- FromRow
- Derives
snowflake_connector_rs::FromRowfor a struct.