def empty_temp_db(): # create a temp database for testing with tempfile.TemporaryDirectory() as tmpdirname: qc.config["core"]["db_location"] = os.path.join(tmpdirname, 'temp.db') qc.config["core"]["db_debug"] = False # this is somewhat annoying but these module scope variables # are initialized at import time so they need to be overwritten qc.dataset.experiment_container.DB = qc.config["core"]["db_location"] qc.dataset.data_set.DB = qc.config["core"]["db_location"] qc.dataset.experiment_container.debug_db = qc.config["core"]["db_debug"] _c = mut.connect(qc.config["core"]["db_location"], qc.config["core"]["db_debug"]) mut.init_db(_c) _c.close() yield
def generate_empty_DB_file(): """ Generate the bare minimal DB file with no runs """ import qcodes.dataset.sqlite_base as sqlite_base v0fixturepath = os.path.join(utils.fixturepath, 'version0') os.makedirs(v0fixturepath, exist_ok=True) path = os.path.join(v0fixturepath, 'empty.db') if os.path.exists(path): os.remove(path) conn = sqlite_base.connect(path) sqlite_base.init_db(conn)