예제 #1
0
    def setUp(self):
        self.db_session = DBSession()
        self.connection = engine.connect()

        # # Configure Search DDL triggers.
        Base.metadata.drop_all(self.connection)
        Base.metadata.create_all(self.connection)

        self.client = TestClient(app)
예제 #2
0
async def create_admin():
    """If admin account doesn't exist, create it."""
    from app.database import DBSession
    from app.controllers.account import create_account
    from app.controllers.account import get_account_by_email

    db_session = DBSession()
    account_data = {
        "email": "*****@*****.**",
        "password": "******",
        "first_name": "Admin",
        "last_name": "Istrator",
        "is_system_admin": True,
        "is_active": True,
    }
    account_obj = get_account_by_email(db_session, email=account_data["email"])
    if account_obj:
        return

    create_account(db_session, **account_data)
    db_session.close()
예제 #3
0
def get_db():
    try:
        db_session = DBSession()
        yield db_session
    finally:
        db_session.close()
예제 #4
0
 def add(instance):
     session = DBSession()
     session.add(instance)
     session.commit()
예제 #5
0
 def query(cls):
     return DBSession().query(cls)
예제 #6
0
 def delete(instance):
     session = DBSession()
     session.delete(instance)
     session.commit()