R
ruud grosmann
hi group,
I have problems connection to an oracle database using dbi.
machine: debian lenny,
ruby: ruby 1.8.7 (2008-08-11 patchlevel 72)
Using several descriptions on internet I have downloaded
ruby-oci8-1.0.3.tar and installed it.
The result is that I can open a database using a OCI8 object, but not
using a DBI object. I understood that the way to use DBI is by
installing that package.
Following a test script and its output. Can someone tell me what could
be wrong? Do I need to install another package?
thanks in advance, Ruud
============ script
require 'oci8'
require 'dbi'
connection = OCI8.new( 'user', 'pwd', 'database')
cursor = connection.exec('select id, description, name from role')
while r = cursor.fetch()
puts r.join(',')
end
cursor.close
connection.logoff
puts "and now using DBI"
puts DBI.available_drivers
db = DBI.connect('DBI:OCI8:database', 'user', 'pwd')
sql = "select id from role"
dbh.select_all(sql) do | row |
p row
end
dbh.disconnect
==============output
1,admin,admin
2,traffic,traffic
and now using DBI
dbi:ODBC:
/usr/lib/ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect': IM002 (0)
[iODBC][Driver Manager]Data source name not found and no default
driver specified. Driver could not be loaded (DBI:atabaseError)
from /usr/lib/ruby/1.8/dbi.rb:424:in `connect'
from /usr/lib/ruby/1.8/dbi.rb:215:in `connect'
from leesdb:18
I have problems connection to an oracle database using dbi.
machine: debian lenny,
ruby: ruby 1.8.7 (2008-08-11 patchlevel 72)
Using several descriptions on internet I have downloaded
ruby-oci8-1.0.3.tar and installed it.
The result is that I can open a database using a OCI8 object, but not
using a DBI object. I understood that the way to use DBI is by
installing that package.
Following a test script and its output. Can someone tell me what could
be wrong? Do I need to install another package?
thanks in advance, Ruud
============ script
require 'oci8'
require 'dbi'
connection = OCI8.new( 'user', 'pwd', 'database')
cursor = connection.exec('select id, description, name from role')
while r = cursor.fetch()
puts r.join(',')
end
cursor.close
connection.logoff
puts "and now using DBI"
puts DBI.available_drivers
db = DBI.connect('DBI:OCI8:database', 'user', 'pwd')
sql = "select id from role"
dbh.select_all(sql) do | row |
p row
end
dbh.disconnect
==============output
1,admin,admin
2,traffic,traffic
and now using DBI
dbi:ODBC:
/usr/lib/ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect': IM002 (0)
[iODBC][Driver Manager]Data source name not found and no default
driver specified. Driver could not be loaded (DBI:atabaseError)
from /usr/lib/ruby/1.8/dbi.rb:424:in `connect'
from /usr/lib/ruby/1.8/dbi.rb:215:in `connect'
from leesdb:18