Esempio n. 1
0
def create_volume():
    ed_user = Volume(name='vmax_vol',
                     fullname='vmax_vol pool 1 ',
                     pool='pool1')
    # Let's add the user and its addresses we've created to the DB and commit.
    session.add(ed_user)
    session.commit()
Esempio n. 2
0
def create_user():
    ed_user = User(name='ed', fullname='Ed Jones', password='******')
    ed_user.addresses = [
        Address(email_address='*****@*****.**'),
        Address(email_address='*****@*****.**')
    ]

    # Let's add the user and its addresses we've created to the DB and commit.
    session.add(ed_user)
    session.commit()
Esempio n. 3
0
def commit_unlock_tables(session):
    """Commit and unlock tables for supported backends: MySQL and PostgreSQL"""
    session.commit()
    session.execute('COMMIT')  # execute COMMIT on DB backend
    # because sqlalchemy session does not guarantee
    # exact boundary correspondence to DB backend transactions
    # We must guarantee DB commits transaction before UNLOCK

    # unlock
    if is_mysql():
        session.execute('UNLOCK TABLES')
Esempio n. 4
0
def commit_unlock_tables(session):
    """Commit and unlock tables for supported backends: MySQL and PostgreSQL"""
    try:
        session.execute('COMMIT')  # execute COMMIT on DB backend
        session.commit()
        # because sqlalchemy session does not guarantee
        # exact boundary correspondence to DB backend transactions
        # We must guarantee DB commits transaction before UNLOCK

        # unlock
        if is_mysql():
            session.execute('UNLOCK TABLES')
        # postgres automatically releases lock at transaction end
    except db_exc.DBDataError as exc:
        LOG.exception('Database backend experienced data error.')
        raise congress_exc.DatabaseDataError(data=exc)
Esempio n. 5
0
def commit_unlock_tables(session):
    """Commit and unlock tables for supported backends: MySQL and PostgreSQL"""
    try:
        session.execute('COMMIT')  # execute COMMIT on DB backend
        session.commit()
        # because sqlalchemy session does not guarantee
        # exact boundary correspondence to DB backend transactions
        # We must guarantee DB commits transaction before UNLOCK

        # unlock
        if is_mysql():
            session.execute('UNLOCK TABLES')
        # postgres automatically releases lock at transaction end
    except db_exc.DBDataError as exc:
        LOG.exception('Database backend experienced data error.')
        raise congress_exc.DatabaseDataError(data=exc)