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

    Add a GUID column to the runs table and assign guids for all existing runs
    """

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

    if n_run_tables == 1:
        with atomic(conn) as conn:
            sql = "ALTER TABLE runs ADD COLUMN guid TEXT"
            transaction(conn, sql)
            # now assign GUIDs to existing runs
            cur = transaction(conn, 'SELECT run_id FROM runs')
            run_ids = [r[0] for r in many_many(cur, 'run_id')]

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

            for run_id in pbar:
                query = f"""
                        SELECT run_timestamp
                        FROM runs
                        WHERE run_id == {run_id}
                        """
                cur = transaction(conn, query)
                timestamp = one(cur, 'run_timestamp')
                timeint = int(np.round(timestamp*1000))
                sql = f"""
                        UPDATE runs
                        SET guid = ?
                        where run_id == {run_id}
                        """
                sampleint = 3736062718  # 'deafcafe'
                cur.execute(sql, (generate_guid(timeint=timeint,
                                                sampleint=sampleint),))
    else:
        raise RuntimeError(f"found {n_run_tables} runs tables expected 1")

    Perform the upgrade from version 0 to version 1

    Add a GUID column to the runs table and assign guids for all existing runs
    
Perform the upgrade from version 0 to version 1
Add a GUID column to the runs table and assign guids for all existing runs
Perform the upgrade from version 0 to version 1 Add a GUID column to the runs table and assign guids for all existing runs
def perform_db_upgrade_0_to_1(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())
    if n_run_tables == 1:
        with atomic(conn) as conn:
            sql = "ALTER TABLE runs ADD COLUMN guid TEXT"
            transaction(conn, sql)
            cur = transaction(conn, 'SELECT run_id FROM runs')
            run_ids = [r[0] for r in many_many(cur, 'run_id')]
            pbar = tqdm(range(1, len(run_ids) + 1), file=sys.stdout)
            pbar.set_description("Upgrading database; v0 -> v1")
            for run_id in pbar:
                query = f"""
                        SELECT run_timestamp
                        FROM runs
                        WHERE run_id == {run_id}
                        """
                cur = transaction(conn, query)
                timestamp = one(cur, 'run_timestamp')
                timeint = int(np.round(timestamp*1000))
                sql = f"""
                        UPDATE runs
                        SET guid = ?
                        where run_id == {run_id}
                        """
                sampleint = 3736062718  
                cur.execute(sql, (generate_guid(timeint=timeint,
                                                sampleint=sampleint),))
    else:
        raise RuntimeError(f"found {n_run_tables} runs tables expected 1")
def perform_db_upgrade_0_to_1 ( 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 ( ) ) if n_run_tables == 1 : with atomic ( conn ) as conn : sql = "ALTER TABLE runs ADD COLUMN guid TEXT" transaction ( conn , sql ) cur = transaction ( conn , 'SELECT run_id FROM runs' ) run_ids = [ r [ 0 ] for r in many_many ( cur , 'run_id' ) ] pbar = tqdm ( range ( 1 , len ( run_ids ) + 1 ) , file = sys . stdout ) pbar . set_description ( "Upgrading database; v0 -> v1" ) for run_id in pbar : query = f"""
                        SELECT run_timestamp
                        FROM runs
                        WHERE run_id == {run_id}
                        """ cur = transaction ( conn , query ) timestamp = one ( cur , 'run_timestamp' ) timeint = int ( np . round ( timestamp * 1000 ) ) sql = f"""
                        UPDATE runs
                        SET guid = ?
                        where run_id == {run_id}
                        """ sampleint = 3736062718 cur . execute ( sql , ( generate_guid ( timeint = timeint , sampleint = sampleint ) , ) ) else : raise RuntimeError ( f"found {n_run_tables} runs tables expected 1" )
Perform the upgrade from version 0 to version 1
Add a GUID column to the runs table and assign guids for all existing runs
Perform the upgrade from version 0 to version 1 Add a GUID column to the runs table and assign guids for all existing runs
"""
    Perform the upgrade from version 0 to version 1

    Add a GUID column to the runs table and assign guids for all existing runs
    """ # now assign GUIDs to existing runs # 'deafcafe'
conn
ConnectionPlus