0

I'm writing a simple website using Flask. When I added time field to the Td class I got

sqlalchemy.exc.OperationalError

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) table td has no column named time

 class Td(db.Model):
        id = db.Column(db.Integer, primary_key=True)
        text = db.Column(db.String(271), nullable=False)
        date = db.Column(db.String())
        time = db.Column(db.String())

I suppose that in production when you manage a big project it's not an option to drop_all() the whole db each time you add new column. Is there a proper way to add a new column?

Andrew
  • 125
  • 1
  • 8
  • here is something that may help you https://stackoverflow.com/questions/7300948/add-column-to-sqlalchemy-table – Jey Savali Nov 17 '19 at 07:57

1 Answers1

0

Try using Flask- Migrate

It can be used to make schema changes to your database without deleting existing data.

Greg Cowell
  • 677
  • 5
  • 16