Crate snowflake_connector

Source
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
MetaData
ResultSetMetaData
QueryFailureStatus
QueryFailureStatus
QueryStatus
QueryStatus
RowType
RowType
SnowflakeConnector
SnowflakeExecutor
SnowflakeExecutorSQLJSON
SnowflakeQueryStatus
SnowflakeSQL
SnowflakeSQLResponse
SnowflakeSQLResult
StatementHandle
A unique tag that identifies a SQL statement request

Enums§

NewSnowflakeConnectorError
Error creating a new SnowflakeConnector
NewSnowflakeConnectorFromFileError
Error creating a new SnowflakeConnector from key paths
QueryCancelError
Error canceling a query
SnowflakeSQLManipulateError
Error retrieving results of SQL manipulation
SnowflakeSQLSelectError
Error retrieving results of SQL selection
SnowflakeSQLTextError
Error retrieving results of SQL statement as text
StatementResult
Whether the query is running or finished

Traits§

DeserializeFromStr
For custom data parsing, ex. you want to convert the retrieved data (strings) to enums
SnowflakeDeserialize

Derive Macros§

SnowflakeDeserialize
Implements SnowflakeDeserialize for struct