Expand description
§Snowflake Connector
Snowflake Connector allows connecting to Snowflake using its SQL API.
§Auto-Generating Tables
Snowflake Connector allows you to generate Snowflake tables by connecting to your database and reading its metadata.
The SNOWFLAKE_PATH
environment variable must be defined for auto-generation of Snowflake tables to work.
Simply define the environment variable that points to a directory in your repository, and create a snowflake_config.toml
file within that directory.
Then, run cargo build
.
The tables will be output into a snowflake_tables.rs
file under the SNOWFLAKE_PATH
directory.
Here is an example snowflake_config.toml
file:
private_key_path = "PATH_TO_PRIVATE_KEY"
public_key_path = "PATH_TO_PUBLIC_KEY"
host = "FIRST-LAST"
account = "FIRST-LAST"
user = "RUST_CLIENT"
role = "ROLE"
warehouse = "WAREHOUSE"
[[databases]]
name = "DATABASE_NAME"
[[databases.tables]]
name = "TABLE_SCHEMA.TABLE_NAME"
# By default, numbers will be signed, if you want them unsigned,
# put the column names in the array below
unsigned = [
"number_type_column_name_that_should_be_unsigned",
"another_one",
"another_another_one"
]
# If a column stores a json value, it can be deserialized into a custom struct
# by providing an exact path to the custom struct that implements `serde::Deserialize`
[databases.tables.json]
menu_item_health_metrics_obj = "crate::snowflake::metrics::Metrics"
# If you want a column to deserialize into an enum
# you can define it like below
[databases.tables.enums]
menu_type = [ # `menu_type` will be deserialized into an enum from the values in the array, each string generates a unique variant
"Ice Cream",
"BBQ",
"Tacos",
"Mac & Cheese",
"Ramen",
"Grilled Cheese",
"Vegatarian",
"Crepes",
"Ethiopian",
"Hot Dogs",
"Poutine",
"Gyros",
"Chinese",
"Indian",
"Sandwiches",
]
# Defining another table all over again, like above
[[databases]]
name = "ANOTHER_DATABASE_NAME"
[[databases.tables]]
name = "ANOTHER_SCHEMA.ANOTHER_TABLE_NAME"
To regenerate tables, either touch
or modify snowflake_config.toml
,
or run cargo clean
, then cargo build
to force rebuild dependencies which rebuilds the tables.
Modules§
- bindings
- chrono
- Chrono: Date and Time for Rust
- data_
manipulation - serde_
json - Serde JSON
Structs§
- Binding
- Meta
Data - ResultSetMetaData
- Query
Failure Status - QueryFailureStatus
- Query
Status - QueryStatus
- RowType
- RowType
- Snowflake
Connector - Snowflake
Executor - Snowflake
ExecutorSQLJSON - Snowflake
Query Status - SnowflakeSQL
- SnowflakeSQL
Response - SnowflakeSQL
Result - Statement
Handle - A unique tag that identifies a SQL statement request
Enums§
- NewSnowflake
Connector Error - Error creating a new SnowflakeConnector
- NewSnowflake
Connector From File Error - Error creating a new SnowflakeConnector from key paths
- Query
Cancel Error - Error canceling a query
- SnowflakeSQL
Manipulate Error - Error retrieving results of SQL manipulation
- SnowflakeSQL
Select Error - Error retrieving results of SQL selection
- SnowflakeSQL
Text Error - Error retrieving results of SQL statement as text
- Statement
Result - Whether the query is running or finished
Traits§
- Deserialize
From Str - For custom data parsing, ex. you want to convert the retrieved data (strings) to enums
- Snowflake
Deserialize
Derive Macros§
- Snowflake
Deserialize - Implements
SnowflakeDeserialize
for struct