Connecting RStudio with Snowflake on MacBook M1


I'm trying to connect to Snowflake in RStudio (odbc and DBI) using unixodbc on a M1 MacBook. The driver is properly set up, as odbc recognises both the driver and the data source:

 # List data sources
       name                                                   description
1 snowflake /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib

 # List drivers
          name attribute                                                         value
1 ODBC Drivers Snowflake                                                     Installed
2    Snowflake    Driver /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib

I've tried two approaches for connecting and both of them eventually failed.

  • First approach: it opens the browser for authenticating, successful log in, but an error is thrown (HTTP error (http error) - code=400).
con <- dbConnect(odbc::odbc(), 
                 .connection_string = "Driver={Snowflake}; 
                                       Role={myrole};", timeout = 10)
Initiating login request with your identity provider. A browser window should have opened for you to complete the login. If you can't see it, check existing browser windows, or your OS settings. Press CTRL+C to abort and try again...
{"message":"Limit Exceeded"}{"message":"Limit Exceeded"}Error: nanodbc/nanodbc.cpp:1021: 00000: [Snowflake][Snowflake] (4) **
**      REST request for URL failed: HTTP error (http error) - code=400.
  • Second approach: authentication successful, but it doesn't really connect to the database as it shows some random empty tables that don't exist (something like A, B, C etc).
con <- odbc::dbConnect(
  driver = "Snowflake",
  server = Sys.getenv("SNOWFLAKE_ACCOUNT"),
  uid = Sys.getenv("SNOWFLAKE_USER"),
  authenticator = "externalbrowser",
  host = "localhost",
  port = 443)

Any idea on how to fix this? I've also tried JDBC instead of ODBC, but it doesn't work on the latest M1 processors. Also, the driver appears to be working with Python, but not with R/RStudio.

Thank you!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.