Issue
I have a values queryset of my values. how can convert it to a csv file.
Its important to export it by postgresql not python. because queryset have too many records.
Solution
after many search and test i found this solution
objects = query.values(field_list)
cursor = connection.cursor()
stdout = BytesIO()
cursor.copy_to(stdout, "(" + unicode(objects.query) + ")", null="", sep=",")
csv = stdout.getvalue()
and postgresql generate csv automatically
Answered By - vorujack
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.