how to export a table to csv or excel format,writer.writerows(cursor.fetchall())