Instead, you use an easy to install royalty-free Python client library whichĬonnects directly to the mxODBC Connect database server over the Python Database Connectivity the Easy Wayīuilding on our mxODBC database interface for Python, mxODBC Connect is designed as client-server application, so you no longer need to find production quality database drivers for all platforms you target with your Python application. Market today in a highly portable, convenient and secure way. Now that is all set up we can finally install the Sequel gem and fire up our Rails console and test this out:ĭb = Sequel.odbc('snowflake', user: ENV, password: ENV)ĭb.execute("USE WAREHOUSE # ").entriesĪfter supplying your warehouse, database, and view you should get back an array of hashes of data from your Snowflake view.The mxODBC Connect ™ Database Interface for Python allows users toĮasily connect Python applications to all major databases on the Using Rails and Sequel to Query Snowflake The odbc.ini file should match the local one from above using the new label for the driver as it is set above. ĭriver=/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib This is an example of the odbcinst.ini file using the same driver that was installed above with a different label that does not match the local driver. This program stores its configuration files in a different place than iODBC and these files will be listed by running: Gem install ruby-odbc -with-odbc-dir=$(brew -prefix unixodbc) If you are on a new M1 Mac you may need to pass in the odbc directory: This can be solved by installing unixodbc: You may need configuration options.Įven though the driver has been installed so that iODBC can use it, the development headers for the ruby-odbc gem do not exist yet. Check the mkmf.log file for more details. noĬould not create Makefile due to some reason, probably lack of necessary libraries and/or headers. When you go to install the ruby-odbc gem you will run into an error: checking for version.h. Now that you have all of that working you would expect to be able to install the ruby-odbc gem and start working in your Rails environment. Now, that was a lot of setup just to get to a prompt where you are able to query Snowflake. If everything is set up properly you will see a “SQL>” prompt and be able to query the database that you have specified in the connection string. This connection string should not be enclosed in quotes and should be in the following format: This will allow you to enter an iODBC connection string for any of the DSNs listed using the ? command. Library/Application Support/iODBC/bin/iodbctest With this file updated with your Snowflake information you can now test the connection using the following command that is included with iODBC: Testing the Snowflake ODBC Installation and Configuration Here is an example of my local odbc.ini file: ĭriver = /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib The real configuration comes into play in the ~/Library/ODBC/odbc.ini file. The ~/Library/ODBC/odbcinst.ini should be set up properly. This driver has its configuration files in ~/Library/ODBC/odbcinst.ini and ~/Library/ODBC/odbc.ini. I chose to not install the optional ODBC Manager and configure the connection manually through the odbcinst.ini and odbc.ini files.Īfter iODBC has been installed the next step is to actually install the ODBC driver. Īt the time of writing the link in the Snowflake documentation ( ) is not currently working. Snowflake actually has pretty good documentation for setting up a local environment for Mac OS. īefore digging into this integration I wanted to get my local environment set up so that I could experiment with querying the data outside of the application while we were settling on the presentation of what was to be included in the Snowflake views. After some research I came to the conclusion that one of the only ways to query the Snowflake views was through an ODBC connection using a combination of and. Recently I received a request to integrate a connection with an existing Rails application.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |