snowflakedb-rs
A lightweight, comprehensive and familiar database driver for the Snowflake SQL Database written natively in Rust.
Features
- Query results in JSON or Arrow
- Stream results in JSON or Arrow RecordSets
- Parse results into
Column,Row,Cellprimatives for easy Rust usage - SQLx inspired API
- Password auth
- Certification auth
- Automatic token renewal
- Managed transactions
- Query bindings (named and anonymous parameters, even batched bindings)
- Describe queries without actual execution
- Custom API hostname for users in Mainland China, or custom enterprise users.
- Async agnostic, supports
tokio,smol, etc - Provide your own HTTP Client, or use
reqwestfeature (See here) -
chronoandbigdecimalparsing of cell values - Lightweight by design with minimal dependencies
- GET/PUT support (WIP)
Motivation
snowflakedb-rs was built to provide all the functionality required to write an Arrow Database Connection Protocol (ADBC) adapter for Snowflake natively in Rust.
At the moment, the only existing library that provides all the features required for an ADBC adapter in Rust is the adbc_snowflake crate. However, adbc_snowflake currently wraps gosnowflake, requiring a Go compiler and bundling the Go runtime with your Rust binary in order to use. Furthermore, adbc_snowflake does not provide any streaming capabilities, which was not ideal.
As such, snowflakedb-rs aims to provide as much of the existing functionality gosnowflake currently provides, without needing to bundle a Go runtime, or call any other external dependencies for that matter. This library directly calls the exact same undocumented API used in gosnowflake.
Additionally, snowflakedb-rs provides many useful primitives that allows you to work with Snowflake directly in idiomatic Rust. The snowflakedb-rs API is partly inspired by SQLx, which should provide a familiar interface for Rust developers.
Whether you plan to develop your own ADBC adapter, or just use Snowflake in idiomatic and familiar Rust, snowflakedb-rs will provide something useful for you.
Installation
You can install snowflakedb-rs using:
You don't need a Golang compiler, just Cargo!
Cargo Feature Flags
# Cargo.toml
= {
version = "1",
= ["auth-cert", "arrow", "chrono", "decimal", "reqwest"]
}
-
arrow: Use arrow as the data exchange medium between Snowflake and Rust. By default, JSON is used. -
auth-cert: Use certificate authentication with Snowflake -
chrono: DeserialiseDATE,TIME,TIMESTAMP_LTZ,TIMESTAMP_NTZ,TIMESTAMP_TZinto chrono types. -
decimal: DeserialiseDECFLOATandFIXEDinto abigdecimal::BigDecimal. -
reqwest: Usereqwestas the underlying HTTP client. Disable if you want to use a custom HTTP client. (See here)
Warning: Its highly recommended to enable the
chronofeature for most people. Snowflake returns Date/Time types in difficult to read ints and floats, and snowflakedb-rs will return these types as aStringof raw numbers ifchronois disabled.
If
decimalif not enabled,DECFLOATandFIXEDwill be returned as af64in when using a JSON Connection.
Enabling
arrowwill also enablechrono.
Usage
Creating a Snowflake Connection
To get a SnowflakeConnection, create a SnowflakeConnectionOptsBuilder and build it with your desired options and authentication strategy (AuthStrategy).
By default, snowflakedb-rs comes with only AuthStrategy::Password. If you enable the auth-cert feature, you will also have AuthStrategy::Certificate.
Here's how you create a SnowflakePool with the Password AuthStrategy:
use ;
async
To get a SnowflakePool, use the SnowflakeConnectionOpts::connect_json() method. This returns a SnowflakePool that will use JSON as the communication protocol between Snowflake and Rust.
To get a SnowflakeConnection, use the SnowflakePool::get() method. This method returns a SnowflakeConnection if one is available, or an Err(SnowflakeError) if all connections are in use.
Queries
Run a SELECT query:
use CellValue;
async
RUN an INSERT statement:
use ;
use ;
async
Create and use a Transaction:
use ;
async
Describe a Query to get its return column types and number of expected parameters:
use ;
async
Apache Arrow
When you enable the arrow feature, you can configure snowflakedb-rs to use the Arrow format for communication with Snowflake's API.
Here's how you configure arrow:
use ;
async
The Arrow SnowflakeConnection supports all the same methods the JSON SnowflakeConnection, and a few additional methods too.
Here is how you directly access the underlying Snowflake RecordBatches returned:
let query = conn
.fetch
.await
.unwrap;
let results = query
.execute
.await
.unwrap;
// Streams RecordBatches as they come in
let mut record_batches = results.record_batches;
while let Some = record_batches.try_next.await.unwrap
Here's how you describe an arrow_schema::Schema:
let query = conn
.fetch
.await
.unwrap;
let describe = query
.describe
.await
.unwrap;
// Gives you an arrow_schema::Schema
let schema = describe.schema;
Using a Custom HTTP Client
By default, no HTTP Client is provided. However, snowflakedb-rs uses HTTP to communicate with Snowflake's APIs.
For the majority of users, its recommended to enabled the reqwest feature and move on with your day. However, if you want to use another HTTP Client, you need to create a Wrapper around you Client and implement the SnowflakeHttpClient trait that is exported.
Example implementation of SnowflakeHttpClient for reqwest::Client:
use SnowflakeHttpClient;
;
You don't have to manually do this if you're already planning to use
reqwest! Use thereqwestfeature. This is only required for other HTTP clients.
Use your HTTP Client:
use ;
async
Contributing
PRs are welcomed! Any help is appreciated. There are a number of TODOs, FIXMEs, and improvements that can be done around the repo. If any of them are tied to a feature you need, please create an issue.
License
Copyright © 2026, Carl Ian Voller. Released under the BSD-3-Clause License.