Re: row_factory and DictCursor
James Henstridge <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Jun 2, 2009 at 11:26 PM, Joel Nothman <[email protected]> wrote: > What do you think of these proposed changes? Unfortunately, it would be hard > to make them backwards compatible, but if few people have written their own > row factories according to the old interface, then the available ones > (DictRow, RealDictRow) will be easy to modify. I think it sounds like a good idea (especially if it can simplify the core code to only have to work in terms of tuples). Compatibility is a concern though, so it'd be useful to know whether anyone is actively using this extension mechanism outside of the DictConnection / RealDictConnection classes. If we do change the API, I think it'd be best to make it exactly the same as the pysqlite API if possible -- that should make it more useful for apps that try to support multiple database backends. As for the _build_fields() bit, psycopg offers a read only rownumber attribute on the cursor that tells you where in the result set you are. Perhaps a row factory could assume that if rownumber is not 0, then the previous cached field mappings are still valid? James.