chenzhongpu
chenzhongpu

Reputation: 6871

Flask-SQLAlchemy: Do I have to create_all if tables existed already?

In the example, it doesn't specify that when and how to execute create_all.

SQLAlchemy.create_all() method to create the tables and database

Suppose I have already created database and tables (also contains data already) in advance, do I still have to execute create_all ?

Upvotes: 0

Views: 197

Answers (1)

Dan Safee
Dan Safee

Reputation: 1618

No you don't. There are some advantages to using create_all in that you can quickly create production and test environments based on the database models that you have made. create_all also prevents having your models not match the actual database since the database was made from the models.

But if you already have the tables created and data already there, it is not required, although it is a good practice and had some advantages.

Upvotes: 2

Related Questions