hello everyone, here's what i've come up with when trying to make a database cursor return rows as associative arrays:
def some_complex_report(request): cursor = connection.cursor() cursor.execute(<come_custom_sql>) rows=cursor.fetchall() fields = [ field[0] for field in cursor.description] d=[ dict( [ (fields[i], row[i]) for i in range(len(row)) ] ) for row in rows ] return render_to_response( '<template file>', {'sql': d} ) but, as you see, it is shamefully inefficient, copying data at least twice. what i'd love to do instead is: def some_complex_report(request): cursor = connection.cursor() cursor.execute(<come_custom_sql>) return render_to_response( '<template file>', {'sql': cursor} ) this way, the template processor can fetch the data row by row, reducing the memory usage to a negligible value. i believe this is how it works when I use the ORM. is this true? if so, Is there a way to separate the query generator and the processor, so that I can supply custom sql queries to the query processor? thanks in advance. regards, burak --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---