Which ODBC?

Hello,

I am investigating ways to connect my Ruby (non-Rails) application on
Windows
to either MSSQL, MySql or Oracle databases. ODBC seems to be a common
way
for accessing them, so I wonder how to best access ODBC from Ruby.

Searching on the Web, I found solutions using DBI, or the ODBC Library
at ODBC Binding for Ruby. Now I wonder:

  • Are there other alternative ODBC interfaces?
  • Are some of them available as gem? Which ones?
  • Are there interfaces written in “plain ruby”, so that the application
    might also run under JRuby? (Of course I can use JDBC on JRuby as an
    alternative - I’m here more interested in Ruby vs. JRuby compatibility).

Any suggestions?

Ronald

i am using Active Record in some non-rails apps.
Very handy. Easy to do also,

shawn

On May 29, 3:09 pm, “Ronald F.” [email protected]
wrote:


Ronald F. [email protected]
Phone: +49-89-452133-162

I don’t know about the pros and cons of alternative ODBC libraries for
Ruby, so can’t say anything there. But here are some other ideas:

  • Why not try out a few of the different ODBC options and evaluate
    them? And, preferably, post here or put up an article somewhere with
    your findings, for the benefit of others ? including me :slight_smile: I’d
    appreciate that as I intend to do some work with Ruby/DBI/ODBC. If you
    don’t I’ll probably do it myself after a while.

  • To use the same code in both Ruby and JRuby, if there are no pure-
    Ruby libraries, you could consider writing a thin wrapper of your own
    with alternative underlying Ruby/DBI and JRuby/JDBC implementations. I
    know this would mean writing more code but it might not be all that
    much, and you’d then have that code to use in other projects as well.
    The ODBC/DBI/JDBC interfaces/API are all roughly similar, so you might
    not have too much work to do, plus you could always bypass your own
    wrapper and call through directly to whichever underlying interface
    you’re really using in a particular app, for any special cases that
    your wrapper can’t handle.

Just my 2c …

Vasudev Ram
Dancing Bison Enterprises

On 5/29/07, Gregory B. [email protected] wrote:

Ruport’s Query support:
http://api.rubyreports.org/

whoops, here’s a direct link:
http://api.rubyreports.org/classes/Ruport/Query.html

On 5/29/07, Ronald F. [email protected] wrote:

  • Are there other alternative ODBC interfaces?

On windows, DBI and ODBC come with the one click installer, that means
you could use if you wanted something pretty raw but still clean:

Ruport’s Query support:
http://api.rubyreports.org/

Or for a little more advanced functionality, Sequel:
http://sequel.rubyforge.org

And ActiveRecord works, too

  • Are some of them available as gem? Which ones?

All three of the above mentioned are

  • Are there interfaces written in “plain ruby”, so that the application
    might also run under JRuby? (Of course I can use JDBC on JRuby as an
    alternative - I’m here more interested in Ruby vs. JRuby compatibility).

Ruby DBI and Ruport are close to running on JRuby, but not quite.
I’d love to see folks help get this up and running though.

Sequel, I’m not sure. I think it’s pure ruby but I don’t know about
the database drivers for ODBC.

And ActiveRecord works, too

Ruport seems a bit of an overkill to me, but I would like to try
DBI and ActiveRecord. I was able to find ActiveRecord, by

gem install -r ActiveRecord

but I don’t see how I could install DBI. According to
Rubyforge, it should be ‘ruby-dbi’
(http://rubyforge.org/projects/ruby-dbi/),
but:

gem install -r ruby-dbi

says:

ERROR: While executing gem … (Gem::GemNotFoundException)

Ronald

On 5/30/07, Ronald F. [email protected] wrote:

but:

gem install -r ruby-dbi

DBI is not available as a gem. It’s somewhat tricky to install on
various systems, but it’s included with the one click installer for
Ruby on windows (as is a suitable odbc driver).

In terms of getting it working with JRuby, good luck, many folks would
be happy to see that happen.