I borrowed the dictfetchall(cursor) code directly from Djangoproject.com
and it works with my code.
But what kind of sorcery is this? How can I output the contents of *desc*?
I want to see what that data looks like.
*desc* = cursor.description
Because I can't follow what's going on here.
for col in *desc*
#_______________________________________________________________________________
https://docs.djangoproject.com/en/1.6/topics/db/sql/#connections-and-cursors
def dictfetchall(cursor):
"Returns all rows from a cursor as a dict."
desc = cursor.description
return [
dict(zip([col[0] for col in desc], row))
for row in cursor.fetchall()
]
#_______________________________________________________________________________
class AltwordManager(models.Manager):
def vote_order(self):
"Returns a 1:M list ordered by votes."
cursor = connection.cursor()
cursor.execute("""
SELECT navi_polls_word.rosword, navi_polls_altword.alt_ros_word,
navi_polls_altword.votes
FROM navi_polls_altword INNER JOIN navi_polls_word
ON (navi_polls_altword.rosword_id=navi_polls_word.id)
""")
#row = cursor.fetchall()
row = dictfetchall(cursor)
return row
#_______________________________________________________________________________
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.