錯誤訊息:.rvm/gems/ruby-1.9.2-p180/gems/dbi-0.4.3/lib/dbi/utils/date.rb:57:in <class:Date>': undefined method
deprecate' for DBI::Date:Class (NoMethodError)
測試用rb
# simple.rb – simple MySQL script using Ruby DBI module
require "dbi"
begin
# connect to the MySQL server
dbh = DBI.connect("dbi:Mysql:mysql: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
執行 $ ruby test.rb 出現下列訊息即成功
Server version: 5.1.51
評論
此文章尚無評論。