문제

In a flask application I create my schema with

db.create_all()

some of the tables should not be created, they are managed externally to the application, how can I tell SqlAlchemy to not create them ?

도움이 되었습니까?

해결책

The command db.create_all() will only create models for those classes that you import into the script you use to run that command. For example, lets say that my models.py file has two classes:

class User(db.Model):

and

class Address(db.Model):

In the script where I run db.create_all, if my file looks like:

from models import User
db.create_all()

my app will only create the User model. Conversely, if my file looks like:

from models import User, Address
db.create_all()

both the User and Address models will be created.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top