#snowflake #sql #client #sql-query

snowflake-connector-rs

A Rust client for Snowflake

12 releases (4 breaking)

new 0.5.1 Jun 13, 2024
0.5.0 Jun 6, 2024
0.4.0 May 30, 2024
0.3.3 May 25, 2024
0.1.0 Dec 4, 2023

#497 in Database interfaces

Download history 328/week @ 2024-02-21 470/week @ 2024-02-28 415/week @ 2024-03-06 464/week @ 2024-03-13 330/week @ 2024-03-20 311/week @ 2024-03-27 301/week @ 2024-04-03 252/week @ 2024-04-10 313/week @ 2024-04-17 299/week @ 2024-04-24 168/week @ 2024-05-01 319/week @ 2024-05-08 650/week @ 2024-05-15 820/week @ 2024-05-22 971/week @ 2024-05-29 603/week @ 2024-06-05

3,090 downloads per month

MIT license

38KB
903 lines

Snowflake Connector for Rust

test Crates.io

A Rust client for Snowflake, which enables you to connect to Snowflake and run queries.

let client = SnowflakeClient::new(
    "USERNAME",
    SnowflakeAuthMethod::Password("PASSWORD".to_string()),
    SnowflakeClientConfig {
        account: "ACCOUNT".to_string(),
        role: Some("ROLE".to_string()),
        warehouse: Some("WAREHOUSE".to_string()),
        database: Some("DATABASE".to_string()),
        schema: Some("SCHEMA".to_string()),
        timeout: Some(std::time::Duration::from_secs(30)),
    },
)?;
let session = client.create_session().await?;

let query = "CREATE TEMPORARY TABLE example (id NUMBER, value STRING)";
session.query(query).await?;

let query = "INSERT INTO example (id, value) VALUES (1, 'hello'), (2, 'world')";
session.query(query).await?;

let query = "SELECT * FROM example ORDER BY id";
let rows = session.query(query).await?;
assert_eq!(rows.len(), 2);
assert_eq!(rows[0].get::<i64>("ID")?, 1);
assert_eq!(rows[0].get::<String>("VALUE")?, "hello");

Dependencies

~11–25MB
~377K SLoC