Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
david_busint
Frequent Visitor

Avoiding including Snowflake credentials in Python script when python script uses Snowflake

Hi everyone,

 

I've been testing runing some forecasting scripts in Power BI desktop where the python script imports the data used to generate the forecast from Snowflake.  The Snowflake connection in the python script has to include my credentials but it's less than ideal from a security point of view to have Power BI reports holdings my Snowflake account credentials within the Python script. 

 

Does anyone know how to get around this?

 

Kind regards,

 

David

1 ACCEPTED SOLUTION
ibarrau
Super User
Super User

Hi. Power Bi has snowflake connector. You should use them to let powerbi keep the credentials encrypted and secured. Then you can run a python step at Query Editor (Transform Data) to keep going if you prefer transforming data that way.

I hope that helps,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

View solution in original post

4 REPLIES 4
v-kpoloju-msft
Community Support
Community Support

Hi @david_busint,

Thank you for reaching out to the Microsoft Fabric Community Forum.

 

Thank you for raising your concern. We really apologize for the inconvenience caused. After reviewing the details you provided, please follow the steps below, which might resolve the issue.

 

  • Store your Snowflake credentials in environment variables to avoid hardcoding them in your script. Use a configuration file for your credentials and ensure it's excluded from version control by adding it to .gitignore.
  • Use key pair authentication instead of username and password for better security and to avoid storing passwords.
  • Utilize secrets management services like aws secrets manager, azure key vault, or Hashi corp vault to securely store and retrieve your credentials.
  • Snowflake now allows managing secrets directly within the platform, enabling secure storage of sensitive information like API keys or passwords.

By implementing these methods, you can ensure that your Snowflake credentials are handled securely and not exposed within your Python scripts.

 

If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

 

Best Regards.

Akash_Varuna
Solution Sage
Solution Sage

Hi @david_busint  Could you please try these

  • Use environment variables and retrieve them in the script with os.getenv().
  • Store credentials in tools like Azure Key Vault, AWS Secrets Manager, or HashiCorp Vault.
  • Use OAuth or key-pair authentication for Snowflake.
  • Import Snowflake data via Power BI dataflows to bypass Python handling credentials.
    If this post helped please do give a kudos and accept this as a solution
    Thanks In Advance

 

 

ibarrau
Super User
Super User

Hi. Power Bi has snowflake connector. You should use them to let powerbi keep the credentials encrypted and secured. Then you can run a python step at Query Editor (Transform Data) to keep going if you prefer transforming data that way.

I hope that helps,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Cheers this seems the best short-term solution. 

 

Now I just need to get the python script to work since for some reason set_index works fine in a regular python scripting tool but not in Snowflake or Power BI. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors