0
votes

I am trying to connect snowflake using python connector but i am facing problem while connecting to a specific role. even i have access to that role at snowflake web application but i am not able to connect with that same role using python connector. i am only able to connect with PUBLIC role.

I am using following script:

conn = snowflake.connector.connect(
                user=USER,
                password=PASSWORD,
                role=ROLE,
                account=ACCOUNT,
                warehouse=WAREHOUSE,
                database=DATABASE,
                schema=SCHEMA,
                autocommit=False
                )

I am getting following error:

DatabaseError: 250001 (08001): Failed to connect to DB: account_name.east-us-2.azure.snowflakecomputing.com:443. Role 'ANALYST_ROLE' specified in the connect string does not exist or not authorized. Contact your local system administrator, or attempt to login with another role, e.g. PUBLIC.

2
Are you sure in the Snowflake UI you can use same database and schema with that role? So not only logging in, but also use the database and schema from your script.Sergiu
yes, i am able to that, even run the script on snowflake ui with same role, schema and databaseshwetank agrawal

2 Answers

0
votes

Here are some hints:

  1. In Snowflake Role names are case sensitive. Maybe you have some quoting issues in your original code, i.e. please check your '', "", lower- or uppercase or simply use the original role name without some quotation marks.
  2. Maybe the role has not enough privileges to operate on your db/schemas and thus it says "not authorized".
  3. You can try to add the role manually before: Account -> Roles
0
votes

I caught the error, I just made a very slight mistake(single character mistake) in my role name. due to very large name, i could not see it. I am able to connect now. the role name mentioned here is fake for security reason so don't assume that.