Answer the question
In order to leave comments, you need to log in
How to replace all values in a column using Flask-SQLAlchemy?
Hello! Googling didn't turn up anything, so I'm asking here.
The table consists of 6 columns. I fill the table with data using two consecutive loops:
the first loop fills the first 5 columns, the second loop fills the remaining 6th column.
The table is filled in the wrong way:
the first loop fills the first 5 columns + 6th column, but writes all NULL values in it. The second loop writes data to the required column, but already far below the existing data, and also fills the first 5 columns with NULL values.
I had an idea to make sure that the second cycle does not add, but replaces the existing 6th column with new data, but I did not find how to implement this.
for i in items:
ticket = i[0]
price = i[18]
value = i[51]
percent = i[20]
date = i[22]
tickets = Base(ticket=ticket,price=price, value=value, percent=percent, date=date)
db.session.add(tickets)
db.session.commit()
for i in items2:
name = i[2]
tickets2 = Base(name=name)
db.session.add(tickets2)
db.session.commit()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question