def app(): app = create_app(TestConfig()) with app.app_context(): db.drop_all() db.create_all() yield app
def _app(config_class, init_scheduler=False) -> Flask: __app: Flask = create_app(config_class, init_scheduler) if config_class is TestingConfig: db.drop_all() db.create_all() return __app
def main(): app = create_app() with app.app_context(): db.drop_all() db.create_all() read_from_file_and_write_to_db() geocode_cities()
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 db(app): _db.app = app with app.app_context(): _db.create_all() yield _db _db.session.close() _db.drop_all()
def db(app): """ Setup our database, this only gets executed once per session. :param app: Pytest fixture :return: SQLAlchemy database session """ _db.drop_all() _db.create_all() return _db
def app() -> Flask: def _app(config_class, init_scheduler=False) -> Flask: __app: Flask = create_app(config_class, init_scheduler) if config_class is TestingConfig: db.drop_all() db.create_all() return __app yield _app db.session.remove() db.drop_all()
def db(): db_ext.create_all() yield db_ext db_ext.drop_all()
def _drop_db(): from backend.extensions import db click.echo('Dropping DB tables.') db.drop_all() db.engine.execute('DROP TABLE IF EXISTS alembic_version;')