English 中文(简体)
我如何妥善安装了Ruby des DBI gem,以便与MySql交谈?
原标题:How do I get Ruby s DBI gem properly installed so that it can talk to MySql?

在我的Windows 7盒子上,I ve安装了Rub.1.9.2,并安装了以下格米:

www.un.org/Depts/DGACM/index_french.htm

  • dbd-mysql (0.4.4)
  • dbi (0.4.5)
  • deprecated (2.0.1)
  • httparty (0.8.1)
  • rubygems-update (1.8.15)

(我使用gem安装)。

我还编写了以下简单测试:

require  rubygems 
require  dbi 

begin
    dbh = DBI.connect("DBI:Mysql:test", "username", "pwd")

    row = dbh.select_one("SELECT VERSION()")
    puts "Server Version: "+row[0]
rescue DBI::DatabaseError => e
    puts "An error occurred"
    puts "Error code: #{e.erriii"
    puts "Error message: #{e.errstriii"
ensure
    # disconnect from server
    dbh.disconnect if dbh
end

不管我如何具体指明连接线,我还是要:

C:CodeConcordance.SE>ruby test_sql.rb
C:/Tools/Ruby192/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:300:in `block in
load_driver : Unable to load driver  Mysql  (underlying error: uninitialized con
stant DBI::DBD::Mysql) (DBI::InterfaceError)
        from C:/Tools/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize 

        from C:/Tools/Ruby192/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:242:
in `load_driver 
        from C:/Tools/Ruby192/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:160:
in `_get_full_driver 
        from C:/Tools/Ruby192/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:145:
in `connect 
        from test_sql.rb:4:in `<main> 

iii

我做了什么错误?

问题回答

https://stackoverflow.com/questions/1208029/193-1-is-not-a-valid-win32-application-bug-with-a-new-rails-application>question。

当你以64个轨道运行系统运行时,你需要将一个新版本的libMySql.dll复制到Ruby目录。 The Best sources for this dll is





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签