Forum: Ruby installed mysql gem on windows but it isn't working

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Grehom (Guest)
on 2007-06-14 12:40
(Received via mailing list)
I installed the 'dbi' gem and tried running this ruby script:

  require 'dbi'

  db_name = "cookbook"
  host_name = "localhost"
  user_name = "cb_user"
  password = "cb_pass"
  dsn = "DBI:mysql:host=#{host_name};database=#{db_name}"


  # Connect to a database, old style
  dbh = DBI.connect(dsn, user_name, password)


  # And finally, disconnect
  dbh.disconnect

output was:
  C:\rubysrcs\ruby_tut>ruby -w test_handle.rb
  C:/Ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:499:in `load_driver':  is
not a class/module (TypeError)
        from C:/Ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in
`_get_full_driver'
        from C:/Ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in
`connect'
        from test_handle.rb:11

unfortunately I am too new to ruby to figure out where to go with
this!  I apologise if you read my same question last week under
different heading but I got no useful answers.
Grehom (Guest)
on 2007-06-15 12:06
(Received via mailing list)
On 14 Jun, 08:38, Grehom <removed_email_address@domain.invalid> wrote:
>   # Connect to a database, old style
> `_get_full_driver'
>         from C:/Ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in
> `connect'
>         from test_handle.rb:11
>
> unfortunately I am too new to ruby to figure out where to go with
> this!  I apologise if you read my same question last week under
> different heading but I got no useful answers.

I waded into this code using the -r debug option and it seems that the
code is failing to find information in the DBD directory.  I don't
know much about the techy stuff but I have the DBI module working fine
under perl, and sure enough when I looked in the
C:\Perl\site\lib\DBD\mysql directory there was a file: GetInfo.pm

Now this led me to unzip the mysql-ruby-windows-2.7.3-r1.zip file and
sure enough, in a similar layout to the perl directory there is a
file:  C:\TMP\ruby-dbi\lib\dbd\Mysql.rb

However to my untutored eye the contents of this file and the perl
file aren't at all similar.

If you've bothered to read this far, I can hear you asking why didn't
you just install the dbi stuff from above mentioned zip, well I did
try with no success, despite having the NMAKE program installed and
trying to set the option --make-prog=nmake

C:\TMP\ruby-dbi> ruby setup.rb clean
entering clean phase...
clean done.

C:\TMP\ruby-dbi> ruby setup.rb config --make-prog=NMAKE
entering config phase...
config done.

C:\TMP\ruby-dbi> ruby setup.rb setup
entering setup phase...
setting #! line to "#!C:/Ruby/bin/ruby"
setting #! line to "#!C:/Ruby/bin/ruby"
C:/Ruby/bin/ruby extconf.rb
checking for sqlite_open() in sqlite.lib... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby/bin/ruby
        --with-sqlite-dir
        --without-sqlite-dir
        --with-sqlite-include
        --without-sqlite-include=${sqlite-dir}/include
        --with-sqlite-lib
        --without-sqlite-lib=${sqlite-dir}/lib
        --with-sqlitelib
        --without-sqlitelib
NMAKE

Microsoft (R) Program Maintenance Utility   Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.

NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.
setup failed
'system NMAKE' failed
try "ruby setup.rb --help" for usage

but this is getting areas which I know nothing about and has me
stumped.  I have had some success in past installing perl modules that
depended upon the NMake program working.

Please there must be someone out there who has the DBI module working
under Windows with MySQL, I really want to develop my ruby skills and
I use MySQL a lot with perl
This topic is locked and can not be replied to.