# -*- coding: utf-8 -*-
from mongoengine import *
class Report( Document) :
name = StringField( )
email = StringField( )
num_orders = StringField( )
num_products = StringField( )
total = StringField( )
import csv
with open ( 'report_result.csv' , 'w' ) as csvfile:
connect( 'order_report_base' )
spamwriter = csv .writer ( csvfile)
for report in Report.objects :
spamwriter.writerow ( [ report.name ] + [ report.email ] + [ report.num_orders ] + [ report.num_products ] + [ report.total ] )
IyAtKi0gY29kaW5nOiB1dGYtOCAtKi0KCmZyb20gbW9uZ29lbmdpbmUgaW1wb3J0ICoKCgpjbGFzcyBSZXBvcnQoRG9jdW1lbnQpOgogICAgbmFtZSA9IFN0cmluZ0ZpZWxkKCkKICAgIGVtYWlsID0gU3RyaW5nRmllbGQoKQogICAgbnVtX29yZGVycyA9IFN0cmluZ0ZpZWxkKCkKICAgIG51bV9wcm9kdWN0cyA9IFN0cmluZ0ZpZWxkKCkKICAgIHRvdGFsID0gU3RyaW5nRmllbGQoKQoKaW1wb3J0IGNzdgp3aXRoIG9wZW4oJ3JlcG9ydF9yZXN1bHQuY3N2JywgJ3cnKSBhcyBjc3ZmaWxlOgogICAgY29ubmVjdCgnb3JkZXJfcmVwb3J0X2Jhc2UnKQogICAgc3BhbXdyaXRlciA9IGNzdi53cml0ZXIoY3N2ZmlsZSkKICAgIGZvciByZXBvcnQgaW4gUmVwb3J0Lm9iamVjdHM6CiAgICAgICAgc3BhbXdyaXRlci53cml0ZXJvdyhbcmVwb3J0Lm5hbWVdICsgW3JlcG9ydC5lbWFpbF0gKyBbcmVwb3J0Lm51bV9vcmRlcnNdICsgW3JlcG9ydC5udW1fcHJvZHVjdHNdICsgW3JlcG9ydC50b3RhbF0p