qcodes/dataset/sqlite/db_upgrades/__init__.py
def perform_db_upgrade_1_to_2(conn: ConnectionPlus) -> None:
    """
    Perform the upgrade from version 1 to version 2

    Add two indeces on the runs table, one for exp_id and one for GUID
    """

    sql = "SELECT name FROM sqlite_master WHERE type='table' AND name='runs'"
    cur = atomic_transaction(conn, sql)
    n_run_tables = len(cur.fetchall())

    pbar = tqdm(range(1), file=sys.stdout)
    pbar.set_description("Upgrading database; v1 -> v2")

    if n_run_tables == 1:
        _IX_runs_exp_id = """
                          CREATE INDEX
                          IF NOT EXISTS IX_runs_exp_id
                          ON runs (exp_id DESC)
                          """
        _IX_runs_guid = """
                        CREATE INDEX
                        IF NOT EXISTS IX_runs_guid
                        ON runs (guid DESC)
                        """
        with atomic(conn) as conn:
            # iterate through the pbar for the sake of the side effect; it
            # prints that the database is being upgraded
            for _ in pbar:
                transaction(conn, _IX_runs_exp_id)
                transaction(conn, _IX_runs_guid)
    else:
        raise RuntimeError(f"found {n_run_tables} runs tables expected 1")

    Perform the upgrade from version 1 to version 2

    Add two indeces on the runs table, one for exp_id and one for GUID
    
Perform the upgrade from version 1 to version 2
Add two indeces on the runs table, one for exp_id and one for GUID
Perform the upgrade from version 1 to version 2 Add two indeces on the runs table one for exp_id and one for GUID
def perform_db_upgrade_1_to_2(conn: ConnectionPlus) -> None:
    sql = "SELECT name FROM sqlite_master WHERE type='table' AND name='runs'"
    cur = atomic_transaction(conn, sql)
    n_run_tables = len(cur.fetchall())
    pbar = tqdm(range(1), file=sys.stdout)
    pbar.set_description("Upgrading database; v1 -> v2")
    if n_run_tables == 1:
        _IX_runs_exp_id = """
                          CREATE INDEX
                          IF NOT EXISTS IX_runs_exp_id
                          ON runs (exp_id DESC)
                          """
        _IX_runs_guid = """
                        CREATE INDEX
                        IF NOT EXISTS IX_runs_guid
                        ON runs (guid DESC)
                        """
        with atomic(conn) as conn:
            for _ in pbar:
                transaction(conn, _IX_runs_exp_id)
                transaction(conn, _IX_runs_guid)
    else:
        raise RuntimeError(f"found {n_run_tables} runs tables expected 1")
def perform_db_upgrade_1_to_2 ( conn : ConnectionPlus ) -> None : sql = "SELECT name FROM sqlite_master WHERE type='table' AND name='runs'" cur = atomic_transaction ( conn , sql ) n_run_tables = len ( cur . fetchall ( ) ) pbar = tqdm ( range ( 1 ) , file = sys . stdout ) pbar . set_description ( "Upgrading database; v1 -> v2" ) if n_run_tables == 1 : _IX_runs_exp_id = """
                          CREATE INDEX
                          IF NOT EXISTS IX_runs_exp_id
                          ON runs (exp_id DESC)
                          """ _IX_runs_guid = """
                        CREATE INDEX
                        IF NOT EXISTS IX_runs_guid
                        ON runs (guid DESC)
                        """ with atomic ( conn ) as conn : for _ in pbar : transaction ( conn , _IX_runs_exp_id ) transaction ( conn , _IX_runs_guid ) else : raise RuntimeError ( f"found {n_run_tables} runs tables expected 1" )
Perform the upgrade from version 1 to version 2
Add two indeces on the runs table, one for exp_id and one for GUID
Perform the upgrade from version 1 to version 2 Add two indeces on the runs table one for exp_id and one for GUID
"""
    Perform the upgrade from version 1 to version 2

    Add two indeces on the runs table, one for exp_id and one for GUID
    """ # iterate through the pbar for the sake of the side effect; it # prints that the database is being upgraded
conn
ConnectionPlus