def drop_table(): """Drops the pypi.Package table from the database.""" Package.query.delete() # Drop all rows. db.session.commit() Package.__table__.drop(db.engine) # Drop the table. db.session.commit() db.create_all() assert [] == Package.query.all()
def create_all(): setup_logging('create_all') app = create_app(parse_options()) log = logging.getLogger(__name__) with app.app_context(): tables_before = set(db.engine.table_names()) db.create_all() tables_after = set(db.engine.table_names()) created_tables = tables_after - tables_before for table in created_tables: log.info('Created table: {}'.format(table))
def create_all(): setup_logging('create_all') app = create_app(parse_options()) log = logging.getLogger(__name__) with app.app_context(): tables_before = {t[0] for t in db.session.execute('SHOW TABLES')} db.create_all() tables_after = {t[0] for t in db.session.execute('SHOW TABLES')} created_tables = tables_after - tables_before for table in created_tables: log.info('Created table: {}'.format(table))
def create_all(): """Create all database tables.""" db.create_all()