Use
If you iterate manually with a for-loop, you must add row by row with
Use a cache if you want to speed up requests.
cw.writerows
on the query.If you iterate manually with a for-loop, you must add row by row with
cw.writerow
(without s at the end).@admin_role.route('/download') @login_required def post(): si = StringIO() cw = csv.writer(si) cw.writerows(Book.query.all()) output = make_response(si.getvalue()) output.headers["Content-Disposition"] = "attachment; filename=export.csv" output.headers["Content-type"] = "text/csv" return outputFor safety reasons you should limit the query and use a paginate function.
Use a cache if you want to speed up requests.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!