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

Question: Why is uri a required argument? #890

Closed
s-banach opened this issue Jul 10, 2023 · 9 comments · Fixed by #923
Closed

Question: Why is uri a required argument? #890

s-banach opened this issue Jul 10, 2023 · 9 comments · Fixed by #923

Comments

@s-banach
Copy link

s-banach commented Jul 10, 2023

I'm currently using snowflake-connector-python like this:

conn = snowflake.connector.connect(
        user=...,
        password=...,
        authenticator=...,
        account=...,
        warehouse=...,
        role=...,
)

Then I use conn to query whatever database/schema I may need.

In contrast, I'm looking at the documentation here:
https://arrow.apache.org/adbc/0.5.1/driver/snowflake.html
It seems that uri is required, and every accepted uri format asks for a database.

Can anyone clarify how to use this driver the same way I use snowflake-connector-python?
Thanks for your time and consideration.

@lidavidm
Copy link
Member

Hmm, it probably shouldn't be. #841 is a similar question about R

@lidavidm lidavidm added this to the ADBC Libraries 0.6.0 milestone Jul 10, 2023
@zeroshade
Copy link
Member

Interestingly this appears to be an issue solely with the documentation. Looking at the code, as far as I can tell "uri" isn't required, you can specify the connection options just like in the python connector.

python connector option --> adbc connection option

user --> username
password --> password
account --> adbc.snowflake.sql.account
warehouse --> adbc.snowflake.sql.warehouse
role --> adbc.snowflake.sql.role
authenticator --> adbc.snowflake.sql.auth_type

All of these are in the documentation along with the available options for auth_type

@lidavidm
Copy link
Member

We might just need some examples then.

@thomasaarholt
Copy link

Hello! There is a check in the cython code to ensure that uri is not None.

If uri is a downstream required string, then it might be better to allow uri to be None in the connect functions (in __init__ and dbapi.py in the snowflake code), but construct it from the other kwargs if uri=None.

@lidavidm
Copy link
Member

#923 will make uri fully optional so you can just specify the properties above instead.

@pkit
Copy link

pkit commented Jun 12, 2024

It still doesn't work at all and there's zero documentation on how it should be configured.
I.e.:
adbc_driver_snowflake.dbapi.connect(conn_kwargs={"account": "XXXXX"}) : Nope
adbc_driver_snowflake.dbapi.connect(db_kwargs={"account": "XXXXX"}) : Nope
adbc_driver_snowflake.dbapi.connect(account="XXXXX") : Nope
All result in adbc_driver_manager.OperationalError: IO: 260000: account is empty

Essentially making the connector totally unusable when password includes any special symbols (because connecting with URI fails miserably too).

@lidavidm
Copy link
Member

Does https://arrow.apache.org/adbc/current/driver/snowflake.html#sso-authentication help?

import adbc_driver_snowflake.dbapi
# This will open a new browser tab, and block until you log in.
adbc_driver_snowflake.dbapi.connect(db_kwargs={
    "adbc.snowflake.sql.account": "foobar",
    "adbc.snowflake.sql.auth_type": "auth_ext_browser",
    "username": "jdoe@example.com",
})

All options: https://arrow.apache.org/adbc/current/driver/snowflake.html#client-options

@pkit
Copy link

pkit commented Jun 12, 2024

It's not an SSO, just regular, normal account with user:password.
Fortunately I've found out that it fails on password because it tries to URL-decode it and stumbles on % sign.
So, changing % -> %25 in all passwords helps. And it starts working with URI. Non URI access doesn't work though.

@lidavidm
Copy link
Member

The example is for SSO, but it's to demonstrate that the option is "adbc.snowflake.sql.account": "foobar"

The URL-decoding is...odd, but that appears to be a behavior of the Snowflake client or server

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

Successfully merging a pull request may close this issue.

5 participants