def create_app(settings_override=None): """ Create a Flask application using the app factory pattern. :return: Flask app """ app = Flask(__name__, instance_relative_config=True) app.config.from_object("config.settings") app.config.from_pyfile("settings.py", silent=True) if settings_override: app.config.update(settings_override) app.register_blueprint(page) app.register_blueprint(api) # GraphQL app.add_url_rule( "/graphql", view_func=GraphQLView.as_view("graphql", schema=schema, graphiql=True), ) # Mutate the flask app apply_extensions(app) with app.app_context(): db.create_all() return app
def initdb(drop): """Initialize the database.""" if drop: click.confirm( 'This operation will delete the database, do you want to continue?', abort=True) db.drop_all() click.echo('Drop tables.') db.create_all() click.echo('Initialized database.')
def setUp(self): """ Define test variables and initialize app""" params = {'DEBUG': False, 'TESTING': True} self.app = create_app(settings_override=params) self.client = self.app.test_client() self.contact = { 'username': '******', 'firstName': 'Aristotle', 'lastName': 'David' } # binds the app to the current context with self.app.app_context(): db.create_all()
def setUp(self): db.init_app(self.app) db.create_all()
def setUp(self): self.redis = get_redis_instance() db.create_all()
def create_all(): db.create_all()
def init_db_command(): print("Init DB") db.create_all()
def create_tables(): db.create_all()
def init_db(): db.create_all()
from src import create_app from src.extensions import db app = create_app() createDb = False # run the app. Docker needs this if __name__ == "__main__": app.run(debug=False, port=8080, host='0.0.0.0') if createDb: print("Creating database tables...") db.create_all() #Creates all tables print("Done!")
def setup_sqlalchemy(): db.create_all()