Skip to content Skip to sidebar Skip to footer

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

Solution 1:

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)
db.create_all()
db.session.commit()

Post a Comment for "Sqlalchemy Create Tables"