freaking code code code … I wish I knew what I was doing wrong ?

31Oct/091

ruby and mysql on OSX 10.6

here are some note on installing ruby on OSX ... as usual this probably will not work for anyone and these are just some notes on mistakes I made:

  • I used the installed version of ruby on OSX 10.6 - Snow Leopard
  • Install the 64 bit version of MySQL from the mysql site (link - and selec the x_86_64, I've used the 5.1.40 installation)
  • install ruby dbi module (dbi-0.4.3) : sudo gem install dbi
  • install ruby dbd module (dbd-mysql-0.4.3):  sudo gem install dbd-mysql

I've also installed mysql (mysql-2.8.1) (though I don't think you need it with DBI/DBO described above). this is the command line I used to install it:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

note: the mistake I made earlier was to not use the "x86_64" parameter and I (I think) as a result for the following error message :`load_driver': Could not load driver (uninitialized constant MysqlError) (DBI::InterfaceError)

So after this I was able to execute the simple DB queries via the ruby dbi interface:

begin
    # connect to the MySQL server
    dbh = DBI.connect("DBI:Mysql:#{$DB}:#{$DB_SERVER}", $DB_USER, $DB_PW)
    # 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

Comments (1) Trackbacks (0)
  1. Thank you for the solution.


Leave a comment


No trackbacks yet.