Created
November 26, 2017 13:20
-
-
Save anshumanv/66f6c27385fe0f54bcf581a5192645ef to your computer and use it in GitHub Desktop.
Generic python script to init a SQLAlchemy Database in Flask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!flask/bin/python | |
from migrate.versioning import api | |
from config import SQLALCHEMY_DATABASE_URI | |
from config import SQLALCHEMY_MIGRATE_REPO | |
from app import db | |
import os.path | |
db.create_all() | |
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO): | |
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository') | |
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO) | |
else: | |
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment