New rubier and sql

Hi everyone,

Iv inherited some ruby code that talks to a sql db and iv never used
ruby before.

Ive tried to poke around to understand where the error below is coming
from but to no result.

C:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:264:in `initialize': wrong number
of arguments (1 for 2) (ArgumentError)
        from C:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:264:in `exception'
        from C:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:264:in `raise'
        from C:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:264:in `load_driver'
        from C:/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
        from C:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:242:in `load_driver'
        from C:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:160:in
`_get_full_driver'
        from C:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:145:in `connect'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.21/lib/active_record/connection_adapters/sqlserver_adapter.rb:775:in
`connect'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.21/lib/active_record/connection_adapters/sqlserver_adapter.rb:211:in
`initialize'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.21/lib/active_record/connection_adapters/sqlserver_adapter.rb:26:in
`new'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.21/lib/active_record/connection_adapters/sqlserver_adapter.rb:26:in
`sqlserver_connection'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in
`send'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in
`new_connection'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in
`checkout_new_connection'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in
`checkout'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in
`loop'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in
`checkout'
        from C:/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in
`checkout'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in
`connection'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in
`retrieve_connection'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:121:in
`retrieve_connection'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:113:in
`connection'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2934:in
`quoted_table_name'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1520:in
`find_one'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1511:in
`find_from_ids'
        from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:590:in
`find'
        from dtr_upload.rb:72
        from dtr_upload.rb:63:in `each'
        from dtr_upload.rb:63

and the bit of code is

ActiveRecord::Base.establish_connection(
:adapter => “sqlserver”,
:mode => “ODBC”,
:dsn => “DSN”,
:username => “USERNAME”,
:password => “PASSWORD”
)

Any answers or info would be greatly appreciated.

Hi install dbi driver so that u can access i suppose.

  1. Download the Ruby/DBI distribution from the Ruby/DBI web site,
    unpack and cd into the directory created by unpacking the distribution
    file. For example:

    gunzip dbi-0.1.1.tar.gz
    tar -xvzf dbi-0.1.1.tar
    cd ruby-dbi

  2. Install the Ruby/DBI ODBC driver:

    ruby setup.rb config --with=dbi,dbd_odbc
    ruby setup.rb setup
    ruby setup.rb install

  3. To test the Ruby/DBI ODBC driver with your Easysoft ODBC data
    source, create a Ruby script named ruby-dbi-odbc-example and add these
    lines

    require ‘dbi’

    Replace MY_DSN with the name of your ODBC data

    source. Replace and dbusername with dbpassword with

    your database login name and password.

    DBI.connect(‘dbi:ODBC:MY_DSN’, ‘dbusername’, ‘dbpassword’) do |
    dbh |

    Replace mytable with the name of a table in your database.

    dbh.select_all(‘select * from mytable’) do | row |
    p row
    end
    end

  4. Run ruby-dbi-odbc-example:

    ruby ruby-dbi-odbc-example

Here is the source guide.

http://www.easysoft.com/developer/languages/ruby/rails.html

Thanks,
Srikanth J

http://srikanthjeeva.blogspot.com

George Mcrand wrote:

Hi everyone,

Any answers or info would be greatly appreciated.

From a quick look it appears as though your dbi gem is out of date…

try “sudo gem update”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs