Member-only story
Using Snowflake with Python and Copilot
I like to play around with Snowflake. Also with Python. And then also combining the 2, for cases such as generating SQL using Python and/or Jinja and executing this code in Snowflake. Or do some provisioning of a trial based on a fixed set of SQL files that I want to execute.
I use a config file to store the Snowflake credentials. The format of this json file is:
{
"account":"pqfc-gt555",
"user":"HDYGBBD",
"password":"&YBF(_NNC",
"warehouse": "",
"database": "",
"schema": ""
}This config is somewhere in my laptop folder structure. In my case, I have a folder called ‘git’ with a lot of github repo’s. The config file can be in the git folder or in one of the folders below.
The code to grab the contents of this config file:
def get_conn():
with open('sfconfig.json', 'r') as file:
data = json.load(file)
user = data['user']
password = data['password']
account = data['account']
conn = snowflake.connector.connect(
user=user,
password=password,
account=account
)
return connI have an issue to fix here: run my code without bothering where my config file resides. And as I am a very slow Python developer (don’t use it often enough I guess) I decided to use Microsoft Copilot…