Example #1
0
def init_db():
    try:
        # if app.debug: # 但开发告一段落时将这里改成 if app.debug: db.drop_all()以使只在开发模式下清空表,
        db.drop_all()  # 但之前这样做以使得无论本地开发还是部署到appfog等云上都可以正常运行(开发时)
        db.create_all()
    except:
        pass
Example #2
0
def setup_databases(app=createApp()):

    with app.app_context():
        db.drop_all()
        db.create_all()
        setup_users()
        setup_timeslots()
Example #3
0
def init():
    import application.data as data
    from application import db
    from application.persistence import user_persistence, category_persistence, report_persistence

    db.drop_all()
    db.create_all()

    for user_data in data.users:
        user = User(email=user_data['email'],
                    password=user_data['password'],
                    user_id=user_data['id'])
        user_persistence.save(user)

    for category_data in data.categories:
        category = Category(name=category_data['name'],
                            category_id=category_data['id'])
        category_persistence.save(category)

    for report_data in data.reports:
        user_id = report_data['user_id']
        category_id = report_data['category_id']
        report = Report(lat=report_data['lat'],
                        lng=report_data['lng'],
                        description=report_data['description'],
                        time=report_data['time'],
                        user=user_persistence.get(user_id),
                        category=category_persistence.get(category_id),
                        report_id=report_data['id'])
        report_persistence.save(report)
    return redirect(url_for('index'))
    def setUp(self):
        app.config['LOGIN_DISABLED'] = True
        app.config['VIEW_COUNT_ENABLED'] = False

        db.drop_all()
        db.create_all()
        self.search_api = app.config['AUTHENTICATED_SEARCH_API']
        self.client = app.test_client()
Example #5
0
 def drop_table(cls):
     if ORM == 'peewee':
         cls.model.drop_table(True)
     elif ORM == 'sql-alchemy':
         with app.app_context():
             db.session.remove()
             db.drop_all()
     elif ORM == 'mongo_engine':
         cls.model.drop_collection()
    def setUp(self):
        app.config["TESTING"] = True,
        db.drop_all()
        db.create_all()
        self.app = app
        self.client = app.test_client()

        with app.test_request_context():
            user_datastore.create_user(email='*****@*****.**',
                                       password=encrypt_password('password'))
            db.session.commit()
Example #7
0
def setupdb():
    """
    Create all database tables
    """
    db.drop_all()
    db.create_all()

    # scaffold some basic data
    db.session.add(Location(name="Uber", address="800 Market St., San Francisco, CA"))
    db.session.add(Location(name="Home", address="Sacramento St., San Francisco, CA"))
    db.session.commit()
Example #8
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--reset_db", action='store_true', help="Delete all code in database")

    import controllers
    import models

    args = parser.parse_args()

    app = create_app()
    if args.reset_db:
        db.drop_all()
    db.create_all()

    populate()
    app.run(host=app.config['HOST'], port=app.config['PORT'])
Example #9
0
  def load():
    # Refresh the database
    db.drop_all()
    db.create_all()

    with warnings.catch_warnings():
      warnings.simplefilter('ignore')
      # This throws a warning about a named ranged ... we don't care 
      workbook = load_workbook(filename=application.config['QASSIGNMENTS_FILE_URI'], read_only=True)

    sheet = workbook['q Assignments']

    parser = SheetParser(sheet)
    for data in parser.parse():
      entry = Entry(*data)
      db.session.add(entry)

    db.session.commit()
    def setUp(self):
        db.drop_all()
        db.create_all()
        self.app = app
        self.client = app.test_client()

        user = User(email='*****@*****.**',
                    password='******',
                    name='noname',
                    gender='M',
                    date_of_birth=datetime.datetime.now(),
                    current_address='nowhere',
                    previous_address='nowhere',
                    blocked=False,
                    view_count=0)

        db.session.add(user)
        db.session.commit()
        self.lrid = uuid.uuid4()
        self.roles = ['CITIZEN']
Example #11
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
Example #12
0
def drop_all():
    if prompt_bool("Are you sure want to drop all you datas?"):
        db.drop_all()
Example #13
0
 def tearDown(self):
   with self.app.app_context():
     db.session.remove()
     db.drop_all()
Example #14
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
Example #15
0
def after_feature(context, feature):
    db.session.remove()
    db.drop_all()
    context.ctx.pop()
Example #16
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.ctx.pop()
Example #17
0
def delete_db():
    db.drop_all()
    db.create_all()
    return('Hello World')
Example #18
0
from application import db
from application.models import *

db.drop_all()
db.create_all()

print("DB created.")
Example #19
0
 def tearDown(self):
     """Clear db after a test"""
     db.session.remove()
     db.drop_all()
 def tearDown(self):
     with self.app.app_context():
         db.session.remove()
         db.drop_all()
Example #21
0
 def tearDown(self):
     """Clear db between tests"""
     db.session.remove()
     db.drop_all()
Example #22
0
    def setUp(self):
        db.drop_all()
        db.create_all()

        db.session.commit()
Example #23
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
Example #24
0
 def teardown(self):
     db.session.remove()
     db.drop_all()
     self.ctx.pop()
Example #25
0
def drop_db():
    """
    Exclui todas as tabelas
    """
    from application import models
    db.drop_all()
Example #26
0
def dropdb():
    if prompt_bool(
        "Are you sure you want to lose all your data"):
        db.drop_all()
Example #27
0
 def tearDown(self):
     """
     Will be called after every test
     """
     db.session.remove()
     db.drop_all()
Example #28
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
Example #29
0
from application import db
from application.models import position, player
db.drop_all()
db.create_all()