Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete Connection Instructions on page /integrations/snowflake.html #963

Open
edglazer opened this issue Dec 11, 2023 · 5 comments
Open

Comments

@edglazer
Copy link

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!

@edublancas
Copy link

hey @edglazer do you have any suggestions on what information we should add?

@edglazer
Copy link
Author

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>:@<account_identifier>/<database_name>/<schema_name>?warehouse=<warehouse_name>&role=<role_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).

@edglazer
Copy link
Author

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!!

@edublancas
Copy link

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!

@edglazer
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants