sample = session.query(Samples) if form.back_drop.data: outfile = open('samples.txt', 'w') outtsv = csv.writer(outfile, delimiter='\t') for record in sample.all(): outtsv.writerow([record.id, record.samplename, record.phenotype, record.alt_samplename, record.exome_data, record.Sample_detail, record.Disease_name, record.Disease_Abbreviation, record.Lineage]) outfile.close() return send_file('../samples.txt', as_attachment = True)
まあこんな感じ。
参照
https://stackoverflow.com/questions/2952366/dump-csv-from-sqlalchemy