Snowflake integration
The SnowflakeConnection
class enables seamless connectivity and data operations on Snowflake within the Datalake infrastructure. It is designed for AI agents and developers who need to read/write structured data securely and efficiently from Snowflake databases.
Requirements
A valid Snowflake account
A user with appropriate read/write access
The
groclake.datalake.connection
module
Class: SnowflakeConnection
SnowflakeConnection
Handles secure connection establishment, data querying, and writing to Snowflake.
Constructor
Parameters:
config
(dict
): Connection configuration dictionary containing:KeyDescriptionExample Valueuser
Snowflake username
"your_user"
password
Snowflake password
"your_password"
account
Snowflake account identifier
"xyz12345.us-east"
warehouse
Compute warehouse name
"COMPUTE_WH"
database
Database to connect to
"your_database"
schema
Schema within the database
"your_schema"
Method: connect()
connect()
Establishes a live connection to the Snowflake instance using the provided credentials.
Example:
Method: read(query: str) → list[dict]
read(query: str) → list[dict]
Executes a SELECT
query and returns the result as a list of dictionaries.
Example:
Method: write(query: str, data: tuple)
write(query: str, data: tuple)
Executes an INSERT
, UPDATE
, or DELETE
query with parameterized values.
Example:
Method: close()
close()
Closes the active Snowflake connection.
Example:
✅ Full Example
🛡️ Best Practices
Always store credentials securely using environment variables or secrets management tools.
Use parameterized queries to avoid SQL injection.
Limit access privileges for the user specified in the config for safer operation
Last updated