Hi all,

I've had a look through the tickets but can't find anything in relation to
why DictCursor is not the default for all cursor() created manually.

I can see the snippet needed was removed here:
https://code.djangoproject.com/changeset/5970

Examples of how to use the dictfetchall() are here:
http://www.revolunet.com/snippets/snippet/dictcursor-for-raw-sql-using-django
http://www.mail-archive.com/django-users@googlegroups.com/msg25368.html

In this case, my code is:
cursor = connection.cursor(row_factory = MySQLdb.cursors.DictCursor)

            _sql = """
                SELECT
                    SUM(is_spam) as is_spam,
                    SUM(is_image_blocked) as is_image_blocked,
                    SUM(IF(dl_job_state = 2, 1, 0)) as dl_job_success,
                    COUNT(*) as total_rows

                FROM
                    fourchan_post
                WHERE
                    id >= 22350944 AND
                    id < 22360944
            """
            cursor.execute(_sql)
            print cursor.fetchall()

((Decimal('0'), Decimal('52'), Decimal('4159'), 9998L),)

However, it should return the field names too..

Could someone indicate if there is a reason for this, or if I should be
filing a bug report?

Cal

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to