示例#1
0
def initialize_database():
    with current_app.app_context():
        db.create_all()
    yield db
    with current_app.app_context():
        try:
            db.session.commit()
        except Exception as exception:
            app_logger.warning(f"Exception occurred: {exception}")
            pass
        db.session.remove()
        db.drop_all()
示例#2
0
def drop_and_rebuild_sql():
    app = create_app()
    context = app.app_context()
    context.push()

    # define working database
    working_database = config.DATABASE_NAME

    # drop working database
    print(f"Dropping database: {working_database}")
    db.drop_all()

    # recreate working database
    print(f"Creating database: {working_database}")
    db.create_all()

    context.pop()
示例#3
0
from app.server import db
from app.server.api.models.Tournament import Tournament
from app.server.api.models.TournametsToObjects import TournamentsToObject
from app.server.api.models.user import User
from app.server.api.models.contestant import Contestant
from app.server.api.models.team import Team
from app.server.api.models import *


db.drop_all()
db.create_all()

db.session.commit()
示例#4
0
 def tearDown(self):
     CommonTestWithDatabaseSupport.tearDownClass()
     db.session.remove()
     db.drop_all()
     app.config[
         'SQLALCHEMY_DATABASE_URI'] = config.Flask.SQLALCHEMY_DATABASE_URI
示例#5
0
 def setUp(self):
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
     db.drop_all()
     db.create_all()
 def tearDown(self):
     db.session.remove()
     db.drop_all()
示例#7
0
def drop_db():
    """Drops the db tables."""
    db.drop_all()
示例#8
0
 def tearDownClass(cls):
     db.session.remove()
     db.drop_all()
示例#9
0
 def setUp(self):
     db.drop_all()
     db.create_all()
示例#10
0
 def tearDownClass(cls):
     db.session.remove()
     db.drop_all()
示例#11
0
 def setUp(self):
     db.drop_all()
     db.create_all()
示例#12
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     super(BaseTestCase, self).tearDown()