def syncdb(): from cal.models import User from social.apps.flask_app import models print 'dropping all' db.drop_all() print 'creating all' db.create_all() print 'done'
def db(app, request): from cal import db db.init_app(app) db.create_all() def teardown(): db.drop_all() request.addfinalizer(teardown) return db
def db(app, request): from cal import db db.init_app(app) db.configure_mappers() db.create_all() make_searchable() yield db db.session.close() # prevent py.test from hanging db.drop_all()
def create(ctx, scraper): """Create database and run scrapers""" db.configure_mappers() # needed for SQLAlchemy-Searchable db.create_all() update.invoke(ctx)
import yaml from cal import app, db, User, update_fb_events, update_engineering_events with app.app_context(): db.create_all() # Populate the user database with open("cal/groups.yml") as fin: users = yaml.load(fin) for username, ids in users.items(): if User.query.filter_by(name=username).first() is None: new_user = User(name=username) new_user.fb_id = ids.get("fb", None) db.session.add(new_user) db.session.commit() update_fb_events() update_engineering_events()