I have a problem connecting my application to a database. I think this
is a ruby problem though Im running ruby on rails, but let me explain.
The thing is that I want to execute queries upon several different
databases by using DBI/DBD and not activerecord. For this I have created
a simple ruby class with the responsibility of fetching different data.
This class looks something like the this:
# connect to the MySQL server
dbh = DBI.connect(“DBI:mysql:localhost”, “username”, “password”)
# get server version string and display it
row = dbh.select_one(“SELECT …”)
rescue DBI::DatabaseError => error
puts “An error occurred”
# disconnect from server
dbh.disconnect if dbh
#same as above, different database
When these methods are executed i get the following error:
Could not load driver (undefined local variable or method `e’ for
Anyone have a sollution for this? I have tried following every guide
there is to connect ruby to a database (installation of dbi/dbd). Maybe
someone could explain what im doing wrong?