qcodes/dataset/sqlite/connection.py
def atomic(conn: ConnectionPlus) -> Iterator[ConnectionPlus]:
    """
    Guard a series of transactions as atomic.

    If one transaction fails, all the previous transactions are rolled back
    and no more transactions are performed.

    NB: 'BEGIN' is by default only inserted before INSERT/UPDATE/DELETE/REPLACE
    but we want to guard any transaction that modifies the database (e.g. also
    ALTER)

    Args:
        conn: connection to guard
    """
    with DelayedKeyboardInterrupt():
        if not isinstance(conn, ConnectionPlus):
            raise ValueError('atomic context manager only accepts '
                             'ConnectionPlus database connection objects.')

        is_outmost = not(conn.atomic_in_progress)

        if conn.in_transaction and is_outmost:
            raise RuntimeError('SQLite connection has uncommitted '
                               'transactions. '
                               'Please commit those before starting an atomic '
                               'transaction.')

        old_atomic_in_progress = conn.atomic_in_progress
        conn.atomic_in_progress = True

        try:
            if is_outmost:
                old_level = conn.isolation_level
                conn.isolation_level = None
                conn.cursor().execute('BEGIN')
            yield conn
        except Exception as e:
            conn.rollback()
            log.exception("Rolling back due to unhandled exception")
            raise RuntimeError("Rolling back due to unhandled exception") from e
        else:
            if is_outmost:
                conn.commit()
        finally:
            if is_outmost:
                conn.isolation_level = old_level
            conn.atomic_in_progress = old_atomic_in_progress

    Guard a series of transactions as atomic.

    If one transaction fails, all the previous transactions are rolled back
    and no more transactions are performed.

    NB: 'BEGIN' is by default only inserted before INSERT/UPDATE/DELETE/REPLACE
    but we want to guard any transaction that modifies the database (e.g. also
    ALTER)

    Args:
        conn: connection to guard
    
Guard a series of transactions as atomic.
If one transaction fails, all the previous transactions are rolled back
and no more transactions are performed.

'BEGIN' is by default only inserted before INSERT/UPDATE/DELETE/REPLACE
but we want to guard any transaction that modifies the database
Guard a series of transactions as atomic . If one transaction fails all the previous transactions are rolled back and no more transactions are performed . ' BEGIN ' is by default only inserted before INSERT / UPDATE / DELETE / REPLACE but we want to guard any transaction that modifies the database
def atomic(conn: ConnectionPlus) -> Iterator[ConnectionPlus]:
    with DelayedKeyboardInterrupt():
        if not isinstance(conn, ConnectionPlus):
            raise ValueError('atomic context manager only accepts '
                             'ConnectionPlus database connection objects.')
        is_outmost = not(conn.atomic_in_progress)
        if conn.in_transaction and is_outmost:
            raise RuntimeError('SQLite connection has uncommitted '
                               'transactions. '
                               'Please commit those before starting an atomic '
                               'transaction.')
        old_atomic_in_progress = conn.atomic_in_progress
        conn.atomic_in_progress = True
        try:
            if is_outmost:
                old_level = conn.isolation_level
                conn.isolation_level = None
                conn.cursor().execute('BEGIN')
            yield conn
        except Exception as e:
            conn.rollback()
            log.exception("Rolling back due to unhandled exception")
            raise RuntimeError("Rolling back due to unhandled exception") from e
        else:
            if is_outmost:
                conn.commit()
        finally:
            if is_outmost:
                conn.isolation_level = old_level
            conn.atomic_in_progress = old_atomic_in_progress
def atomic ( conn : ConnectionPlus ) -> Iterator [ ConnectionPlus ] : with DelayedKeyboardInterrupt ( ) : if not isinstance ( conn , ConnectionPlus ) : raise ValueError ( 'atomic context manager only accepts ' 'ConnectionPlus database connection objects.' ) is_outmost = not ( conn . atomic_in_progress ) if conn . in_transaction and is_outmost : raise RuntimeError ( 'SQLite connection has uncommitted ' 'transactions. ' 'Please commit those before starting an atomic ' 'transaction.' ) old_atomic_in_progress = conn . atomic_in_progress conn . atomic_in_progress = True try : if is_outmost : old_level = conn . isolation_level conn . isolation_level = None conn . cursor ( ) . execute ( 'BEGIN' ) yield conn except Exception as e : conn . rollback ( ) log . exception ( "Rolling back due to unhandled exception" ) raise RuntimeError ( "Rolling back due to unhandled exception" ) from e else : if is_outmost : conn . commit ( ) finally : if is_outmost : conn . isolation_level = old_level conn . atomic_in_progress = old_atomic_in_progress
Guard a series of transactions as atomic.
Guard a series of transactions as atomic .
"""
    Guard a series of transactions as atomic.

    If one transaction fails, all the previous transactions are rolled back
    and no more transactions are performed.

    NB: 'BEGIN' is by default only inserted before INSERT/UPDATE/DELETE/REPLACE
    but we want to guard any transaction that modifies the database (e.g. also
    ALTER)

    Args:
        conn: connection to guard
    """
conn
ConnectionPlus
connection to guard
connection to guard