On Fri, Apr 10, 2009 at 1:24 PM, MS <fretka1...@gmail.com> wrote: > > Hi Malcolm! > > > > then is there any good (built-in) way > > > to write custom SQL queries wich would return dicts instead of tuples? > > > > You know the order the values will be returned in and you know the names > > of the columns. So you can create an iterator that returns the > > dictionary results: > > > > def dict_iterator(cursor, col_names): > > for row in cursor.fetchall(): > > yield dict(zip(col_names, row)) > > > > > Yes, of course I can write it. But isn't a framework supposed to > relieve us from such a boilerplate code? > Especially that it was in the framework already. Strange... > > Regards > MS > > > > Take a look at the values() method on a queryset: http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields
Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---