Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to use ConnectionPlus as a context manager #5314

Open
jenshnielsen opened this issue Aug 11, 2023 Discussed in #5309 · 0 comments
Open

Make it possible to use ConnectionPlus as a context manager #5314

jenshnielsen opened this issue Aug 11, 2023 Discussed in #5309 · 0 comments

Comments

@jenshnielsen
Copy link
Collaborator

Discussed in #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant