jupysql
jupysql copied to clipboard
Incomplete Connection Instructions on page /integrations/snowflake.html
I'm looking at instructions for other databases (Redshift, MySQL) and comparatively it seems as though the Snowflake instructions are incomplete. The instructions seem to load the Penguins CSV into memory, and doesn't actually show any interaction with Snowflake? I'm struggling to get Snowflake working with JupyterLab and JupySQL, but this configuration page seems to be missing crucial data. Any help is appreciated!
hey @edglazer do you have any suggestions on what information we should add?
Yes! I was able to get things working, with help from this section of the Snowflake docs: https://docs.snowflake.com/en/developer-guide/python-connector/sqlalchemy#connection-parameters
Specifically, the more detailed URL string description:
'snowflake://<user_login_name>:
I followed your excellent instructions on adding password to keyring, then used this code to connect:
from sqlalchemy import create_engine
import keyring
%load_ext sql
password = keyring.get_password("MYDB_NAME", "myusername")
db_url = f"snowflake://myusername:{password}@xxyyyy.region-name/MYDB_NAME/MYSCHEMA?warehouse=MYWAREHOUSE_NAME?role=MYROLE"
engine = create_engine(db_url)
%sql engine
Then super simple test:
%sql select current_time
Also, this might be out of scope, but: For me this was enough to connect correctly, but wouldn't let me actually query. My DBA needed to also GRANT USAGE ON WAREHOUSE warehouse_name TO ROLE myrole_name; to overcome errors that blocked the query from completing. I found the answer in the Snowflake community forums and on this Stack Overflow answer https://stackoverflow.com/a/63218159 (even though the question pertains to R).
I also periodically get an error about needing to select the warehouse with USE WAREHOUSE command, so I periodically have to re-run: %sql USE WAREHOUSE mywarehouse_name
Again, maybe out of scope for your instructions, but if it's helpful to get others querying successfully I figure it's worth sharing. Thanks!!
thanks a lot for sharing this, I'll keep this issue open so we remember to incorporate your findings in our user guide.
feel free to share any other feedback! It's pretty difficult for us to find all these weird config edge cases for all databases so we really appreciate it when our community helps us document them!
If I think of anything else, I'll share it here! Glad to help, I think the work you're doing on JupySQL is great!