I need to write data into snowflake database, I have the below script, but I want to write data without giving username and password, is there any other way? #NOTE - I have to run this script in databricks.
import json
import snowflake.connector
# Set up the Snowflake connection parameters
conn = snowflake.connector.connect(
user='your_username',
password='your_password',
account='your_account_name',
warehouse='your_warehouse'
)
# Create a cursor object to execute SQL statements
cursor = conn.cursor()
# Assuming `json_data` contains the fetched JSON data
parsed_data = json.loads(json_data)
# Iterate through the parsed data and insert it into Snowflake
for record in parsed_data:
# Assuming your table has columns like `column1`, `column2`, etc.
query = f"INSERT INTO your_table (column1, column2) VALUES ('{record['key1']}', '{record['key2']}')"
cursor.execute(query)
# Commit the changes
conn.commit()
cursor.close()
conn.close()