MySQL Forums
Forum List  »  Ruby

Re: Ruby Mysql inset variable
Posted by: Raveendran P
Date: August 22, 2008 10:08PM

Hi All,

I got simple solution

require 'mysql'

my_array= ["google.com","yahoo.com"]

db = Mysql::new("localhost", "root", "", "new_development")

my_array.each do |a|
puts a
b = a.collect{|x| x = "'" + x + "'"}
puts b
c = b.join(",")
puts c
sql = "INSERT INTO sites VALUES (3,#{c},0,0);"
db.query(sql)
end

Regards,
P.Raveendran
RF,Chennai,
http://raveendran.wordpress.com

Options: ReplyQuote


Subject
Written By
Posted
July 01, 2008 11:48PM
Re: Ruby Mysql inset variable
August 22, 2008 10:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.