How to install Ruby DBI module?

Discussion in 'Ruby' started by Justin To, Jul 1, 2008.

  1. Justin To

    Justin To Guest

    I downloaded the mysql-ruby-2.8pre4, which I guess is the database
    driver, and dbi-0.2.0. I have the folders, but I have no clue where to
    go from here... all the websites I look at say type this command:
    % ruby extconf.rb
    But where do I type this? And do I type it exactly as is?

    Thanks!
    --
    Posted via http://www.ruby-forum.com/.
    Justin To, Jul 1, 2008
    #1
    1. Advertising

  2. Justin To

    Justin To Guest

    Ok, I typed it into the window's command prompt, but i get this error:
    \mysql-ruby-2.8pre4\extconf.rb --with-mysql-dir

    *** /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. ...
    --
    Posted via http://www.ruby-forum.com/.
    Justin To, Jul 1, 2008
    #2
    1. Advertising

  3. On Tuesday 01 July 2008, Justin To wrote:
    > Ok, I typed it into the window's command prompt, but i get this error:
    > \mysql-ruby-2.8pre4\extconf.rb --with-mysql-dir
    >
    > *** /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. ...


    Have you looked at the mkmf.log file? What does it say?

    Stefano
    Stefano Crocco, Jul 1, 2008
    #3
  4. Justin To

    Justin To Guest

    mkmf.log file:

    have_library: checking for main() in libmysql.lib...
    -------------------- no

    "cl -nologo -Feconftest -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32
    -IC:/ruby/lib/ruby/gems/1.8/gems/mysql-ruby-2.8pre4
    -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -MD -Zi -O2b2xg- -G6 conftest.c
    msvcrt-ruby18-static.lib libmysql.lib oldnames.lib user32.lib
    advapi32.lib ws2_32.lib -link -libpath:"." -libpath:"c:/ruby/lib"
    -stack:0x2000000"
    checked program was:
    /* begin */
    1: #define WIN32_LEAN_AND_MEAN
    2: #include <winsock2.h>
    3: #include <windows.h>
    4:
    5: /*top*/
    6: int main() { return 0; }
    7: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
    /* end */

    "cl -nologo -Feconftest -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32
    -IC:/ruby/lib/ruby/gems/1.8/gems/mysql-ruby-2.8pre4
    -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -MD -Zi -O2b2xg- -G6 conftest.c
    msvcrt-ruby18-static.lib libmysql.lib oldnames.lib user32.lib
    advapi32.lib ws2_32.lib -link -libpath:"." -libpath:"c:/ruby/lib"
    -stack:0x2000000"
    checked program was:
    /* begin */
    1: /*top*/
    2: int main() { return 0; }
    3: int t() { main(); return 0; }
    /* end */

    --------------------
    --
    Posted via http://www.ruby-forum.com/.
    Justin To, Jul 1, 2008
    #4
  5. Justin To

    Justin To Guest

    Also, when I try to perform the steps for setting up DBI ...

    ruby setup.rb config --with=dbi,dbd_mysql
    =>entering config phase...
    =>config done.

    ruby setup.rb setup
    =>no such package or diretory 'dbi'
    =>try "ruby setup.rb --help" for usage
    --
    Posted via http://www.ruby-forum.com/.
    Justin To, Jul 1, 2008
    #5
  6. Justin To

    Justin To Guest

    Justin To wrote:
    > Also, when I try to perform the steps for setting up DBI ...
    >
    > ruby setup.rb config --with=dbi,dbd_mysql
    > =>entering config phase...
    > =>config done.


    ruby setup.rb config (with no options) works with
    ruby setup.rb setup
    ruby setup.rb install

    but how do i test it now in Ruby? What test code?


    --
    Posted via http://www.ruby-forum.com/.
    Justin To, Jul 1, 2008
    #6
  7. Justin To

    Justin To Guest

    With this test code:

    #!/usr/bin/ruby -w
    # simple.rb - simple MySQL script using Ruby DBI module

    require "dbi"

    begin
    # connect to the MySQL server
    dbh = DBI.connect("DBI:Mysql:test:localhost", "testuser",
    "testpass")
    # 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


    I get this error



    c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:329:in `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 mysqltest.rb:8
    --
    Posted via http://www.ruby-forum.com/.
    Justin To, Jul 1, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ulloa
    Replies:
    1
    Views:
    512
    Juha Laiho
    Jul 22, 2004
  2. Jerome Hauss
    Replies:
    0
    Views:
    159
    Jerome Hauss
    Oct 13, 2004
  3. bill
    Replies:
    0
    Views:
    121
  4. Asby

    Mason, DBI, and DBI::Pg

    Asby, Jul 24, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    166
  5. Tim Haynes
    Replies:
    3
    Views:
    130
    Ron Reidy
    Sep 13, 2003
Loading...

Share This Page