row = dbh.select_one(“SELECT VERSION()”)
puts "Server version: " + row[0]
rescue DBI::DatabaseError => e
puts “An error occurred”
puts “Error code: #{e.err}”
puts “Error message: #{e.errstr}”
ensure
# disconnect from server
dbh.disconnect if dbh
end
But i have this error.
load_driver': Unable to load driver 'Mysql' (DBI::InterfaceError) from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:227:in_get_full_driver’
from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:213:in `connect’
from test_dbi.rb:6
When i have installed ruby-dbi i have run this command
It looks like you have the DBD but don’t have the underlying MySQL
driver.
Remember, the DBD is just the frontend to the driver, not the driver
itself.
Thanks Dan.
But now where can i fount the driver for the access.
I have tried to install mysql-ruby-2.7.tar.gz but gives me errors during
the installation.
I’m new and i found some problem to understand what you intend for
‘driver’
Thanks so much
–Andrea R.
When I say ‘driver’, I mean the actual interface to the database,
probably a C
extension. The DBD is just a common interface wrapper over the top of
that.
I’m not familiar with how to install MySQL on Windows but I know others
have
gone through the process. If you search comp.lang.ruby (or google) for
“ruby”
“mysql” + “windows” I suspect you’ll find the answer you’re looking
for.
Andrea,
Did you ever figure this out? I’m having the exact same problem.
Monty
Thanks Dan.
But now where can i fount the driver for the access.
I have tried to install mysql-ruby-2.7.tar.gz but gives me errors during
the installation.
I’m new and i found some problem to understand what you intend for
‘driver’
It looks like you have the DBD but don’t have the underlying MySQL
driver.
Remember, the DBD is just the frontend to the driver, not the driver
itself.
Regards,
Dan
Thanks Dan.
But now where can i fount the driver for the access.
I have tried to install mysql-ruby-2.7.tar.gz but gives me errors during
the installation.
I’m new and i found some problem to understand what you intend for
‘driver’
I even confirmed that the mysql driver was installed by running the
suggested code snippet:
require 'mysql'
puts Mysql::VERSION
which echoed to stdout 20703 as expected. However, when I attempt the
following, I get the "InterfaceError: could not load driver
(uninitialized constant Mysql::Driver).
Any help from a DBI guru would be appreciated.
Sonny.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.