Michael Burton wrote: > Hi everyone, > > I'd like to use column names rather than positions to access the > results of my Django SQL queries. > > For example, > > > cursor = connection.cursor() > > cursor.execute('select a, b, c from foo') > > rows = cursor.fetchall() > > print rows['a'] > > The above code gives me an error saying that 'a' must be an integer. > > It appears that psycopg2 (which I'm using as my underlying db driver) > has the ability to do this by specifying a > cursor_factor=psycopg2.extras.DictCursor in the connection.cursor() > call, but Django 0.96 gives me an error when I try to do this. > > Is there a db-independent way (or any way at all for users of postres) > to use column names in SQL queries instead of positional parameters? > > Thanks > Mike
Try dtuple (bizarro link below because the official dtuple site seems to have been down for ages): http://www.koders.com/python/fid5C251C5BCE2023E3FFC325A119287EFE8C176AD7.aspx Usage: rows = dtuple.fetchrows(cursor) Regards, Jonathan. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---