On Sat, Feb 25, 2012 at 3:12 AM, Brian Stokes <bsto...@gmail.com> wrote: > I have a complicated reporting query that is just much easier for me to deal > with (given our models) as a raw sql query, which I put inside a model and > want > to return as an array of hashes. > > Got that working. But I get all the rows at once, and I'm worried about > memory. > Is there a way, ala DBI module, to loop through the rows from the db handle > as a > result set? >
I suppose you usually don't read the documentation of the libraries you're using... I'm saying that, because if you go in this page [1] and search for title: "Talking directly to your data-store" you will find this solution: zoos = repository(:default).adapter.select('SELECT name, open FROM zoos WHERE open = 1') But to not let you miss all the fun, good reading and next time: RTFM. > while row=sth.fetch do > p row > end > > Thanks! > It's a pleasure to help, Francesco [1] http://datamapper.org/docs/find.html > > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To post to this group, send email to datamapper@googlegroups.com. > To unsubscribe from this group, send email to > datamapper+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/datamapper?hl=en. > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to datamapper@googlegroups.com. To unsubscribe from this group, send email to datamapper+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.