Skip to content

More consistent arguments to db init functions#7967

Merged
jenshnielsen merged 5 commits intomicrosoft:mainfrom
jenshnielsen:jenshnielsen/connection_consistency
Mar 24, 2026
Merged

More consistent arguments to db init functions#7967
jenshnielsen merged 5 commits intomicrosoft:mainfrom
jenshnielsen:jenshnielsen/connection_consistency

Conversation

@jenshnielsen
Copy link
Copy Markdown
Collaborator

All functions take WALmode and db_path as argument. The arguments are not in the same order to maintain backwards compatibility. One could consider changing this by making WAL mode kwarg only

@jenshnielsen jenshnielsen requested a review from a team as a code owner March 24, 2026 12:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes QCoDeS’ SQLite database initialization helpers accept more consistent arguments, allowing callers to explicitly specify a database path and to control journal_mode across related helpers.

Changes:

  • Add an optional db_path parameter to initialise_database (supports str | Path) to initialise/upgrade a database without relying on config db_location.
  • Extend initialised_database_at with a journal_mode parameter and forward it to initialise_or_create_database_at.
  • Expand tests and add a newsfragment documenting the API adjustments.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/qcodes/dataset/sqlite/database.py Extends db init APIs (db_path, journal_mode) and adjusts implementation/docstrings.
tests/dataset/test_database_creation_and_upgrading.py Adds coverage for new db_path and journal_mode behavior and improves typing/path handling in tests.
docs/changes/newsfragments/7967.improved Documents the new/updated init function parameters.
Comments suppressed due to low confidence (1)

src/qcodes/dataset/sqlite/database.py:232

  • The summary line of this docstring is now inaccurate: initialise_database can initialize using the explicit db_path argument, not only the path from the config. Please update the opening description to mention that db_path overrides the config path (and clarify whether/that the config db_location is left unchanged when db_path is provided).
    Initialise a database in the location specified by the config object
    and set ``atomic commit and rollback mode`` of the db. The db is created
    with the latest supported version. If the database already exists the
    ``atomic commit and rollback mode`` is set and the database is upgraded
    to the latest version.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 69.23077% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.56%. Comparing base (115339f) to head (10712fa).
⚠️ Report is 50 commits behind head on main.

Files with missing lines Patch % Lines
src/qcodes/dataset/sqlite/database.py 69.23% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7967      +/-   ##
==========================================
+ Coverage   60.54%   60.56%   +0.01%     
==========================================
  Files         333      333              
  Lines       32230    32245      +15     
==========================================
+ Hits        19514    19529      +15     
  Misses      12716    12716              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jenshnielsen jenshnielsen force-pushed the jenshnielsen/connection_consistency branch from d85bd15 to 10712fa Compare March 24, 2026 13:43
@jenshnielsen jenshnielsen added this pull request to the merge queue Mar 24, 2026
Merged via the queue into microsoft:main with commit b0a7b55 Mar 24, 2026
18 checks passed
@jenshnielsen jenshnielsen deleted the jenshnielsen/connection_consistency branch March 24, 2026 18:37
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

Successfully merging this pull request may close these issues.

3 participants