Dan Pow Dan Pow - 1 year ago 74
Python Question

sqlalchemy create tables

I am coming form django and I wondered how do I create my tables? In django I run makemigration and migrate. What is the command in sqlalchemy? Do I need to write a special script for that?

Answer Source

Short answer is db.create_all(). Here is a piece of this answer

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://login:pass@localhost/flask_app'
db = SQLAlchemy(app)