Hi everyone, I''m working on an app that needs to READ data from a separate database which is constantly being updated by a cron job. If anyone here is familiar with it, it''s a database populated by SNMP data from an open source project called RTG (http://rtg.sourceforge.net/) What I need to do is connect to this database and grab the info. Now, the DB has a number of tables, each of which look something like this: ifOutOctets_1 ifOutOctets_2 ifOutOctets_3 ... ifInOctets_1 ifInOctets_2 ifInOctets_3 ... ifOutUcastPkts_1 ifOutUcastPkts_2 ifOutUcastPkts_3 ... ifInUcastPkts_1 ifInUcastPkts_2 ifInUcastPkts_3 ... interface router Those numbers can increase at any time so creating a model for each one seems like it won''t work out too well in the long run. I started off by creating a model for each and establishing a connection to that DB with those, but like I said that probably won''t work out over time as more tables are added by the cron job outside the scope of the app. Is there some magical Rails way of making something amazingly great like... oh, I don''t know... Rtg.ifOutOctets_1.find(:all)? Haha, OK, something more realistic then? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well, I woudn''t use it for your case, but here it is -> http://magicmodels.rubyforge.org/ But i think going into straight SQL from a activerecord connection object might be a lot simpler. - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Wed, Apr 8, 2009 at 4:57 PM, Jack Bauer <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi everyone, > > I''m working on an app that needs to READ data from a separate database > which is constantly being updated by a cron job. If anyone here is > familiar with it, it''s a database populated by SNMP data from an open > source project called RTG (http://rtg.sourceforge.net/) > > What I need to do is connect to this database and grab the info. Now, > the DB has a number of tables, each of which look something like this: > > ifOutOctets_1 > ifOutOctets_2 > ifOutOctets_3 > ... > ifInOctets_1 > ifInOctets_2 > ifInOctets_3 > ... > ifOutUcastPkts_1 > ifOutUcastPkts_2 > ifOutUcastPkts_3 > ... > ifInUcastPkts_1 > ifInUcastPkts_2 > ifInUcastPkts_3 > ... > interface > router > > Those numbers can increase at any time so creating a model for each one > seems like it won''t work out too well in the long run. > > I started off by creating a model for each and establishing a connection > to that DB with those, but like I said that probably won''t work out over > time as more tables are added by the cron job outside the scope of the > app. Is there some magical Rails way of making something amazingly great > like... oh, I don''t know... Rtg.ifOutOctets_1.find(:all)? > > Haha, OK, something more realistic then? > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That actually seems to work, but why do you think I shouldn''t use it? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
"cos you would still fall into the ifInUcastPkts_3, ifInUcastPkts_2 and ifInUcastPkts_1models problem. Doing it with straight SQL, you could just query the database about which tables are available and read them. A simple "show tables" query would to the trick on MySQL for example. - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Wed, Apr 8, 2009 at 5:48 PM, Jack Bauer <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > That actually seems to work, but why do you think I shouldn''t use it?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---