Need database access in your Ruby application?  With Simba’s ODBC drivers, you can easily connect Ruby to many datasources, including: Salesforce, MongoDB, Spark, Presto and more!

This post will use the Simba Salesforce driver as an example, but the process is almost the same for any of our other drivers.

Follow this three step process to get started:

  1. Install Simba Driver
  2. Install Ruby Dependencies
  3. Connect to your Data

Install and Configure the Simba Driver

We have a free 30 day evaluation for all our drivers.  You can get an evaluation of the Salesforce driver here.

Have a look at our documentation for help installing the driver.  For Salesforce:

Next, configure a Data Source Name (DSN), again see our excellent documentation:

On Windows, test your DSN using the Test button in the configuration screen:


Or see here for OSX or Linux.

Install Ruby Dependencies

If you don’t have Ruby itself installed, head on over to the Ruby page.

After successfully installing Ruby, you’ll need ruby-dbi, including the dbd-odbc gem and ruby-odbc.

Connect to your Data

Now, it’s time for the fun part!

First, create a connection to Salesforce using your DSN.  “Simba Salesforce” is the name of the DSN.  Use your username and password.

Next, execute a query and find out how many columns are in the result set:

Then, print the column names:

Now, fetch and print the results:

And finally, disconnect from the database:

If your Ruby file was called SalesforceSelect.rb, you could run it from the command line like:


the -W0 flag suppresses warnings that show up from DBI.  Suppressing warnings isn’t recommended for production usage.

For more information on using ODBC in Ruby see:

For information on DBI with Ruby on Rails, have a look at: