Hi Im using Ruby as a scripting language. Not for web development, but to connect to a local database on my computer and manipulate it.
Id like to know how I can connect. Do I need to download/import tools? What do I need to get started?
Thanks,
Update
I did gem install mysql2 and ran the following ruby file
require 'mysql2'
#my = Mysql.new(hostname, username, password, databasename)
con = Mysql.new('localhost', 'nverma', 'something', 'ruby')
rs = con.query('select * from contacts')
rs.each_hash { |h| puts h['name']}
con.close
and got the following error:-
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext
/kernel_require.rb:55:in `require': dlopen(/Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.16/lib/mysql2
/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.16/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.16/lib/mysql2/mysql2.bundle
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext
/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext
/kernel_require.rb:135:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext
/kernel_require.rb:135:in `rescue in require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext
/kernel_require.rb:144:in `require'
from sol5.rb:1:in `<main>'
Please help!
mysql2gem.