def create_tables(): db.create_all() if role_repository.get_by_name("admin") is None: role_repository.add_new("admin") role_repository.add_new('user') user_repository.add_new("Потапов", "Дмитрий", "Иванович", "root", "root", 1)
def app(request): """ flask test application :param request: :return: """ # initialize flask application app = create_app('test_app', config.TestConfig) # initialize database with app.app_context(): metadata = MetaData(db.engine) metadata.reflect() # drop database metadata.drop_all() # create tables based on the models db.create_all() # insert test data create_dummy_data() app = FlaskPytest(app) yield app # remove temporary tables in database request.addfinalizer(metadata.drop_all)
def setup_database(app: Flask): """ Creates :param app: the Flask application instance. """ db.init_app(app) with app.app_context(): db.create_all()
def init_vendors(app): from flask_mail import Mail from flask_assets import Environment from application.assets import compile_assets from application.database import db assets = Environment() assets.init_app(app) compile_assets(assets) db.init_app(app) db.create_all() Mail(app)
def create_app(): app = Flask(__name__) configobj = os.environ.get('SMARTLUNCH_SETTINGS') or defaultconfig app.config.from_object(configobj) app.app_context().push() with app.app_context(): db.init_app(app) db.create_all() api = Api(app) set_api_routes(api) JWT(app, authenticate, identity) return app, db
def app(): """ Create the app fixture :return: """ from application.database import db app = create_app({"TESTING": True, "SQLALCHEMY_DATABASE_URI": 'sqlite:///:memory:', 'SECRET_KEY': 's3cr3t!', 'SQLALCHEMY_ECHO': False, 'HTI_ALLOWED_PORTALS': 'https://localhost:8080', 'SQLALCHEMY_TRACK_MODIFICATIONS': False}) with app.app_context(): db.create_all() return app
from application.database import db from application.server import app with app.test_request_context(): db.init_app(app) from application.models import * db.create_all()
def create_tables(): db.create_all() click.echo("Created database")
def app(): app = create_app('Testing') with app.app_context(): db.drop_all() db.create_all() yield app
def create_db(): db.create_all()
def init_database(app): with app.app_context(): db.create_all() return app
def create_database() : db.init_app(app) db.create_all() insert_base_colours()