Well, I got it (Sequel + odbc) working, altho I'm not exactly sure how.  I
went down a number of roads, including trying to get ruby-odbc (
http://www.ch-werner.de/rubyodbc/) installed -- which never succeeded.  But
in order for that to work, I had to install "unixODBC 2.x or libiodbc 3.52
on UN*X", according to rubyodbc's doc, so I ended up installing both.
Anyway, even tho rubyodbc never installed, after I installed everything
else, just for jollies I thought I'd try connecting via Sequel via odbc, and
hallelujah, it worked!

Here's the working code, in all its concise glory:

require 'rubygems'
require 'sequel'
DB = Sequel.odbc('finqueries', :user => "xxxxx", :password => "xxxxx")

dataset = DB['SELECT * FROM pricedata where symbol = \'MSFT\' and pricedate
>= \'8/1/2009\'']

One small step for programming kind...!

For those interested, here's what I got when trying to install
ruby-odbc-0.9997.  Once I told it where "sql.h" was (by adding
"--with-opt-dir /usr/local/include" to the command line), I got this ugly
beast:
/usr/lib/ruby/1.8/mkmf.rb:1155:in `dir_config': private method `split'
called for true:TrueClass (NoMethodError)

Here's the full session:

je...@vostroubuntu:~/Downloads/ruby-odbc-0.9997$ ruby extconf.rb
checking for version.h... yes
checking for sql.h... no
ERROR: sql.h not found
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/ruby1.8
    --with-odbc-dir
    --without-odbc-dir
    --with-odbc-include
    --without-odbc-include=${odbc-dir}/include
    --with-odbc-lib
    --without-odbc-lib=${odbc-dir}/lib
je...@vostroubuntu:~/Downloads/ruby-odbc-0.9997$ ruby extconf.rb
--with-opt-dir /usr/local/include
/usr/lib/ruby/1.8/mkmf.rb:1155:in `dir_config': private method `split'
called for true:TrueClass (NoMethodError)
    from /usr/lib/ruby/1.8/mkmf.rb:1711:in `init_mkmf'
    from /usr/lib/ruby/1.8/mkmf.rb:1736
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
    from extconf.rb:1



On Thu, Aug 6, 2009 at 3:32 PM, Jeremy Evans <[email protected]> wrote:

>
> On Aug 6, 10:47 am, dj <[email protected]> wrote:
> > Hi folks,
> >
> > I tried this:
> >
> > DB = Sequel.connect
> >
> (:adapter=>'odbc',:driver=>'Firebird',:server=>'192.168.0.81',:uid=>"xxxxxxx",:pwd=>"xxxxxxx",:database=>"finqueries")
> >
> > and I get this:
> >
> > /usr/lib/ruby/gems/1.8/gems/sequel-3.3.0/lib/sequel/database.rb:112:in
> > `adapter_class': Could not load odbc adapter:
> > (Sequel::AdapterNotFound)
> >   no such file to load -- odbc
> >         from /usr/lib/ruby/gems/1.8/gems/sequel-3.3.0/lib/sequel/
> > database.rb:147:in `connect'
> >         from /usr/lib/ruby/gems/1.8/gems/sequel-3.3.0/lib/sequel/
> > core.rb:73:in `connect'
> >         from /home/jenko/NetBeansProjects/FinQueryAlpha/lib/
> > test_sequelIB.rb:5
> >
> > I also tried fully qualifying the :database => value (i.e., "c:/
> > finqueries/finqueries.ib"), but no help.
> >
> > Here's my /etc/odbc.ini:
> >
> > [finqueries]
> > Description     = Firebird
> > Driver          = Firebird
> > Dbname          = 192.168.0.81:c:/finqueries/finqueries.ib
> > User            = xxxxxxx
> > Password        = xxxxxxx
> > Role            =
> > CharacterSet    =
> > ReadOnly        = No
> > NoWait          = No
> >
> > I verified that the ODBC is set up properly (outside of Sequel) by
> > connecting via unixodbc isql and issuing "help pricedata" (a table in
> > my db), and it correctly returned all the fieldnames, etc for that
> > table.  It looks like my Sequel config is off, any ideas?
>
> My only experience with the ODBC adapter is on Windows, so you are
> beyond my area of expertise.  Due to the way the ODBC adapter is
> coded, you might want to remove all options except :adapter
> and :database.  You could also try
>
>  Sequel.odbc('finqueries')
>  # or Sequel.odbc('finqueries', :user=>'*', :password=>'*')
>
> If that doesn't work, work with Ruby ODBC in irb and see if you can
> get it to connect and return results.  If you can get a working Ruby
> ODBC connection, it shouldn't be hard to get it working in Sequel.
>
> Jeremy
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to