Qcodes
Qcodes copied to clipboard
Make it possible to use AtomicConnection as a context manager
Updated to reflect change in name of class
Discussed in https://github.com/QCoDeS/Qcodes/discussions/5309
Originally posted by lucas-hak August 10, 2023 Hello, I am trying to make a ConnectionPlus to a database. I am then using this to open a dataset by its id.
import qcodes.dataset as ds
from qcodes.dataset.sqlite.database import connect
with connect(file_path) as db:
dataset = ds.load_by_id(ds_id, db)
However when I run this I get an error.
ValueError: atomic context manager only accepts ConnectionPlus database connection objects.
When investigating this error it seems that the variable db I have initialized is a sqlite3.Connection object and not a ConnectionPlus object.
Am I using the connect function wrong? I want to be able to initialize this in a way that it closes to reduce the chance of keeping my datasets. If someone has advice about how I should handle this that would be greatly appreciated.