As the changeset comment indicates, the snippet you wanted was removed
because it was an internal function that was no longer being used in
Django. Our backwards compatibility promise does not extend to
undocumented internals, so there isn't a bug here.
Regards,
Luke
--
The probability of someone watching you is proportional to the
stupidity of your action.
Luke Plant || http://lukeplant.me.uk/
--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
On 16/06/11 14:10, Cal Leeming [Simplicity Media Ltd] wrote:
> Okay, er.
>
> In reference to the original problem (cursor's not default to
> DictCursor), thus no field names are returned, is there a specific
> reason for this? If not, I'll probably raise a ticket to have it
> considered for change.
I'm not sure exactly what you are asking, because this is about default
behaviour. The choice of a default is usually made according to what is
thought to be the most useful, or according to the way it happens to
have been done in the past.
I also don't know what exactly you are suggesting. Our backwards
compatibility policy means that we aren't going to change the default,
unless other people's code is going to work transparently (which
wouldn't be the case here), so it doesn't really matter what the
original reason was, if there was one. If you are suggesting that we add
some functionality to make use of DictCursor more useful, then certainly
the suggestion is valid.
I'm not sure exactly what you are asking, because this is about default
behaviour. The choice of a default is usually made according to what is
thought to be the most useful, or according to the way it happens to
have been done in the past.
I also don't know what exactly you are suggesting. Our backwards
compatibility policy means that we aren't going to change the default,
unless other people's code is going to work transparently (which
wouldn't be the case here), so it doesn't really matter what the
original reason was, if there was one. If you are suggesting that we add
some functionality to make use of DictCursor more useful, then certainly
the suggestion is valid.
Regards,
for row in cursor:
dictrow = dict( (d[0], c) for d, c in zip(cursor.description, row) )
(izip may be better than zip. Your call.)
Or for the whole result set:
result = [ dict( (d[0],c) for d, c in zip(cursor.description, row) )
for row in cursor ]
--
Question the answers
Why not just put your helper to django snippets?
On Fri, Jun 17, 2011 at 12:25 AM, Cal Leeming [Simplicity Media Ltd]
--
Best regards, Yuri V. Baburov, Skype: yuri.baburov, MSN: bu...@live.com
Because I feel this is just something that should work (or be available) out of the box. There are plenty of other places where Django docs has included code snippets to give the user a heads up, and I think this is the perfect case for one.
If anyone has any objections to this, please let me know, if not ill put in a ticket for consideration.
The thing is, this is a DB API snippet, not a Django snippet
specifically. If Django were a DB API toolbox, then it might make
sense to include it in some form or other. But it's not, so in the
interest of keeping things relatively tidy I'm a -0 on this.
Cheers,
Ian