Ruby and MySQL on windows


#1

Hi,

I’m trying to build a browser driven application using RoR and MySQL. I
have followed one of the tutorials and I can get a web based database
query running fine (Its hard not to with RubyOnRails!)

Now, I don’t want the user to have to got to MySQL to set up tables etc.
I want to do that from the app itself. I was thinking of using the DBI
extension for mysql to talk with the server directly and to that end I
used the simple code simple.rb

require “dbi”

begin
# connect to the MySQL server
dbh = DBI.connect(“dbi:Mysql:research:localhost”, “root”, “”)
# get server version string and display it
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 when I run it i get this error

is not a class/module
c:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:499:in `load_driver’
Press ENTER to close the window…

(The first letter is a blank)

I’m lost :frowning:

thanks
-kg


#2

Followed steps from
http://stonecode.org:2501/stonecodeproductions/published/Ruport,+MySQL+and+Windows

But Is there a way to package it so that my users don’t have to go
through all that?

thanks
-kg

kghose wrote:

Hi,

I’m trying to build a browser driven application using RoR and MySQL. I
have followed one of the tutorials and I can get a web based database
query running fine (Its hard not to with RubyOnRails!)

Now, I don’t want the user to have to got to MySQL to set up tables etc.
I want to do that from the app itself. I was thinking of using the DBI
extension for mysql to talk with the server directly and to that end I
used the simple code simple.rb

require “dbi”

begin
# connect to the MySQL server
dbh = DBI.connect(“dbi:Mysql:research:localhost”, “root”, “”)
# get server version string and display it
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 when I run it i get this error

is not a class/module
c:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:499:in `load_driver’
Press ENTER to close the window…

(The first letter is a blank)

I’m lost :frowning:

thanks
-kg