<div><span class="gmail_quote">On 3/29/06, <b class="gmail_sendername">Ian Bicking</b> <<a href="mailto:ianb@colorstudy.com">ianb@colorstudy.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Greg Ewing wrote:<br>> On 3/29/06, Adam DePrince <<a href="mailto:adam.deprince@gmail.com">adam.deprince@gmail.com</a>> wrote:<br>><br>>>>>> rs.execute( "select upc, description, price from my_table" )
<br>>>>>> data = rs.fetch().fieldby( 'price','upc')<br>>>>>> print type( data )<br>>> <MultiViewMapping><br>><br>> Seems to me it would be a better idea for the DB<br>> module to return tuple-with-attributes objects for
<br>> the rows in the first place, rather than plain<br>> tuples.<br>><br>> When I get around to reworking my custom Firebird<br>> module, I'm going to make it do that.</blockquote><div><br>See the db_row module from
<a href="http://opensource.theopalgroup.com/">http://opensource.theopalgroup.com/</a>. It attempts to provide a tuple-looking (sequence-like) object that also provides "object-like" and "mapping-like" interfaces that is both space and time efficient. While being far from a perfect solution, it does solve many practical problems and is used by many.
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>Which is off-topic here, except to say that a view on the tuple would be<br>
useful in a way that returning a fancy tuple would not, because it could<br>wrap any DB-API-compliant result set. Which might still be off-topic,<br>since the implementation of that particular view would be mostly<br>unrelated to any other view we've talked about here. Except perhaps to
<br>note that patterns for building light and fast views would also be nice.</blockquote><div><br><br>db_api result sets are the tip of the iceberg, though an important start. These annotated tuples can also be used in many other bulk data processing contexts where metadata is either implicit or decoupled with the data values --
e.g., processing csv files with the csv module.<br></div></div><br><br>-Kevin<br><br>