cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Writing to Snowflake from Databricks - sqlalchemy replacement?

brian999
Contributor

I am trying to migrate some complex python load processes into databricks. Our load processes currently use pandas and we're hoping to refactor into Spark soon. For now, I need to figure out how to alter our functions that get sqlalchemy connection engines so I can bring our libraries that use sqlalchemy over to databricks. I see that there is a databricks sqlalchemy library, but there also seems to be a fairly strong option for connecting to Snowflake using a spark session and a JDBC(I think?) connector. Do these spark JDBC sessions work in a similar way to sqlalchemy connection sessions?  

 

Has anyone ever done this before? What is the well-traveled path on this kind of migration?

3 REPLIES 3

shan_chandra
Databricks Employee
Databricks Employee

@brian999  -  spark-snowflake connector is inbuilt into the DBR. Please refer to the below article for examples. 

https://docs.databricks.com/en/connect/external-systems/snowflake.html#read-and-write-data-from-snow...

Please let us know if this helps

Thank you for your response. I am familiar with this documentation, which is rather sparse and the db write part is only in scala from what I can tell. I need to know if, when I start that spark session the session with snowflake stays open, because we create temp tables that rely on being used within the same connection session.  Also, I'd like to know see any example code of using the databricks sqlalchemy library to connect to snowflake.

@brian999  - Below is an example of spark snowflake connector using python. 

https://docs.databricks.com/_extras/notebooks/source/snowflake-python.html

 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group