Exemple #1
0
def initialise_database() -> None:
    """
    Initialise a database in the location specified by the config object
    If the database already exists, nothing happens

    Args:
        config: An instance of the config object
    """
    conn = _connect(get_DB_location(), get_DB_debug())
    # init is actually idempotent so it's safe to always call!
    _init_db(conn)
    conn.close()
    del conn
Exemple #2
0
from qcodes.utils import validators
from qcodes.utils.zmq_helpers import Publisher
from qcodes.instrument_drivers.test import test_instruments, test_instrument

from qcodes.dataset.data_set import new_data_set, load_by_counter, load_by_id
from qcodes.dataset.experiment_container import new_experiment, load_experiment, load_experiment_by_name, \
    load_last_experiment, experiments
from qcodes.dataset.sqlite_settings import SQLiteSettings
from qcodes.dataset.param_spec import ParamSpec
# TODO: do we want this?
from qcodes.dataset.sqlite_base import connect as _connect
from qcodes.dataset.sqlite_base import init_db as _init_db

_c = _connect(config["core"]["db_location"], config["core"]["db_debug"])
# init is actually idempotent so it's safe to always call!
_init_db(_c)
_c.close()
del _c

try:
    get_ipython()  # type: ignore # Check if we are in iPython
    from qcodes.utils.magic import register_magic_class
    _register_magic = config.core.get('register_magic', False)
    if _register_magic is not False:
        register_magic_class(magic_commands=_register_magic)
except NameError:
    pass
except RuntimeError as e:
    print(e)

# ensure to close all isntruments when interpreter is closed