Thank you DeaD_EyE. I tried the solution you proposed and I still have an error.
This is the error I get
This is the error I get
cw.writerows(Book.query.all()) _csv.Error: iterable expected, not Book