Hello,
So I need to run a loop in Ruby to pass some strings into SQLite. Basically I have a table that looks like this:
pID Data
1649,1650,1651|Some data
1643,3|some more data
23,4,5,6,7|More data
Now in my SQLite queries, I will sometimes need to pass all the pIDs for a given line through as one whole string, which I can easily do with the 'i' variable in the loop below:
pID = db.execute( "select distinct pID from pmesh")
pID.each do |i|
end
Where 'i' will equal each pID line and each string looks like this:
1649,1650,1651
1643,3
23,4,5,6,7
But sometimes I will need each string to look like this for me to pass them through:
"1649","1650","1651"
"1643","3"
"23,"4","5","6","7"
Is there any easy loop that I can do that will put quotations and proper commas to make the string appear as I want them to? I know I can do "i = i.to_s() and a = i.split(",")", but I really don't know much else loop-wise after that.
Thanks, Bobby