class productions(db.Model):
"""Model for the stations table"""
__tablename__ = 'production'
id_pro = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255))
prix = db.Column(db.Float)
i have to recover the data from my csv sheet and add it to the database with sqlalchemy if you have ideas to propose to me, thank you in advance
@app.route('/uploader', methods=['Get', 'POST'])
def uploader():
if request.method == 'POST':
file_pro = request.files['production']
print(file_pro)
f = file_pro.read()
csv_data = csv.reader(f)
for line in csv_data:
print(line)
productions.insert().values(id_pro=line[0],name = line[1], prix = line[2] )
return redirect(url_for('prod'))```