示例#1
0
文件: manage.py 项目: dafzal/hackweek
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'
示例#2
0
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
示例#3
0
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()
示例#4
0
def create(ctx, scraper):
    """Create database and run scrapers"""
    db.configure_mappers()  # needed for SQLAlchemy-Searchable
    db.create_all()

    update.invoke(ctx)
示例#5
0
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()