Multiple MySQL Queries with Ruby

I'm having problems with MySQL queries in Ruby. I am using gem mysql.

The configuration is stored in a separate yml file and loaded into the @conf variable. This is my code:

# connect to the database
Mysql::new(@conf['sql_host'], @conf['sql_user'], @conf['sql_password'], @conf['sql_base'])

# it ok when we're doing this
my.query("SELECT * FROM `my_table`") do |e|
  # code
end

# Maybe, I've missed something here...

# really this query will insert value into other table, used SELECT just for testing
# this throws exception: 'query: not connected'
my.query("SELECT * FROM `my_table_2`")

Windows XP
ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
mysql (2.8.1, 2.7.3)
MySQL client version: 5.0.51a

Request a second request request: not connected. '

+5
source share
2 answers

First of all, your program looks fine. I am sure you have a problem with libmysql.dll.

I can reproduce this using libmysql.dll from the Mysql installer.

Download this file and replace it with c: \ ruby ​​\ bin \

http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll

- .

+7

Ruby mysql gem Windows. , , , , ( ).

ActiveRecord ORM ( ) SQLite - Windows Linux MySQL? , , .

0

All Articles