Snowflake Data Warehouse with GO
1. What is a snowflake:
The snowflake is a cloud-based data storage and analytics service, generally termed “data warehouse-as-a-service”. Snowflake Data Exchange allows customers to discover, exchange and securely share data. Mainly corporate users allowed to store and analyze data using cloud-based hardware and software. Snowflake runs on Amazon S3 since 2014, on Microsoft Azure since 2018, and on the Google Cloud Platform since 2019.
2. Prerequisites:
- It can support all the basic os like Red Hat Enterprise Linux or a compatible operating system, macOS (64-bit), Microsoft Windows (64-bit).
- You have to install the browser version mentioned here.
- You can access the snowflakes using the Browser-based web interface or SnowSQL, the Snowflake command-line client.
3. Logging Into Snowflake:
Your snowflake account name always comes in the following ways:
https://<account_name>.snowflakecomputing.com
Where account_name is provided by Snowflake, additionally with account name the regions are also allowed to add which identify the region and cloud platform where your account is hosted.
https://<account_name>.ca-central-1.aws.snowflakecomputing.com
4. Log In Using Web Interface:
- Open the link
https://<account_name>.snowflakecomputing.com.
- If your browser able to support the URL then it will show you the following page and using credentials you can log in.
Now the basics of things are getting done. We have to look into the go driver connectivity.
For GO installation you can check the link.
You can find more driver details here on the GitHub page. You need to install Go language 1.14 or higher for the new driver. The supported operating systems are Linux, Mac OS, and Windows, but you may run the driver on other platforms if the Go language works correctly on those platforms. You can install the driver using the following.
go get -u github.com/snowflakedb/gosnowflake
Connecting The Snowflake Instance:
Firstly we have to be initialized the config struct provided by the snowflake-golang driver. The struct contains the following details
{
"Account":"<your_acc>",
"User":"<username>",
"Password":"<passwd>",
"Database":"<DB>",
"Schema":"<schema>",
"Warehouse":"<Warehouse>",
"Role":"<ROle>",//optional
"Region":"<region>",
}
So following code will connect your snowflake instance with the golang.
You do not have to mention the hostname and port in the above struct until you run the local instance.
Yeah…! You’ve successfully connected the instance now. You can run your queries with the golang “database/sql” driver.
For the more detailing you can read the official docs from here.
Hope you’ve enjoyed the reading. :)