Jason K. Jackson
2006-Jun-24 23:35 UTC
[Rails] Best approach for loading a data object into mysql?
I wrote a rexml script that parses rather big xml files (DOM parsing) and builds an object out of them. This is what it looks like after i parse the xml file and display the object: [#<Article:0xb79e7428 @brand="This is a story from ", @id=5337, @fblurb="burb", @ntype="news type here", @copy="Copyright \302\251 2006 ", @source="source", @body="body", @archive=nil, @att="attribution here", @blurb="Signs and symptoms of food poisoning", @post=nil, @fimage=nil, @head="Health Tip: Eaten Bad Food?">] I have a database schema that looks like this: create table Newsfeeds ( ArticleId varchar(100), PostingDate date, ArchiveDate date, NewsType varchar(100), Headline text, Blurb text, Byline varchar(100), Body text, FeatureBlurb text, FeatureImage text, Attribution varchar(100), Source text, Copyright text, Brand text ); What i need to do is put each parsing from the constructed data object into its place in the database. This is not inside of a rails application. This is a ruby script that will be run from a cron on a linux box. How is the best way to approach this problem? I am a little new at Ruby and i have been going through the docs, but, if anyone can offer a suggestion that would be wonderful. Thanks a lot, your time is much appreciated. -Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060624/a80f9b3c/attachment-0001.html