コード例 #1
0
ファイル: startup.py プロジェクト: dalinhuang/web3dworld
def init_db():
    try:
        # if app.debug: # 但开发告一段落时将这里改成 if app.debug: db.drop_all()以使只在开发模式下清空表,
        db.drop_all()  # 但之前这样做以使得无论本地开发还是部署到appfog等云上都可以正常运行(开发时)
        db.create_all()
    except:
        pass
コード例 #2
0
def setup_databases(app=createApp()):

    with app.app_context():
        db.drop_all()
        db.create_all()
        setup_users()
        setup_timeslots()
コード例 #3
0
ファイル: controller.py プロジェクト: davidmogar/SafePoint
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'))
コード例 #4
0
    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()
コード例 #5
0
ファイル: models.py プロジェクト: k0matoz/sfcd_test
 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()
コード例 #6
0
    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()
コード例 #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()
コード例 #8
0
ファイル: run-server.py プロジェクト: hilfialkaff/matchmate
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'])
コード例 #9
0
ファイル: loaddb.py プロジェクト: drakenya/qassign_api
  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()
コード例 #10
0
    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']
コード例 #11
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
コード例 #12
0
ファイル: manager.py プロジェクト: xrlin/SimpleFlaskBlog
def drop_all():
    if prompt_bool("Are you sure want to drop all you datas?"):
        db.drop_all()
コード例 #13
0
ファイル: test_trips.py プロジェクト: ericso/scrying-me
 def tearDown(self):
   with self.app.app_context():
     db.session.remove()
     db.drop_all()
コード例 #14
0
ファイル: dbtest.py プロジェクト: guitar-academy/gaserver
 def tearDown(self):
     db.session.remove()
     db.drop_all()
コード例 #15
0
ファイル: environment.py プロジェクト: lextoumbourou/flaskage
def after_feature(context, feature):
    db.session.remove()
    db.drop_all()
    context.ctx.pop()
コード例 #16
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.ctx.pop()
コード例 #17
0
ファイル: routes.py プロジェクト: xpetrov/nove_media
def delete_db():
    db.drop_all()
    db.create_all()
    return('Hello World')
コード例 #18
0
ファイル: db_create.py プロジェクト: mjlavin80/horror_genre
from application import db
from application.models import *

db.drop_all()
db.create_all()

print("DB created.")
コード例 #19
0
ファイル: sub_tests.py プロジェクト: GUC-SE-2015/redditFlask
 def tearDown(self):
     """Clear db after a test"""
     db.session.remove()
     db.drop_all()
コード例 #20
0
 def tearDown(self):
     with self.app.app_context():
         db.session.remove()
         db.drop_all()
コード例 #21
0
 def tearDown(self):
     """Clear db between tests"""
     db.session.remove()
     db.drop_all()
コード例 #22
0
    def setUp(self):
        db.drop_all()
        db.create_all()

        db.session.commit()
コード例 #23
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
コード例 #24
0
ファイル: __init__.py プロジェクト: lextoumbourou/flaskage
 def teardown(self):
     db.session.remove()
     db.drop_all()
     self.ctx.pop()
コード例 #25
0
def drop_db():
    """
    Exclui todas as tabelas
    """
    from application import models
    db.drop_all()
コード例 #26
0
ファイル: runserver.py プロジェクト: apexkid/twitterbot
def dropdb():
    if prompt_bool(
        "Are you sure you want to lose all your data"):
        db.drop_all()
コード例 #27
0
 def tearDown(self):
     """
     Will be called after every test
     """
     db.session.remove()
     db.drop_all()
コード例 #28
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
コード例 #29
0
ファイル: create.py プロジェクト: thomaspatten/flask-app
from application import db
from application.models import position, player
db.drop_all()
db.create_all()