Skip to content

db.atomic() method#757

Merged
simonw merged 3 commits into
mainfrom
atomic
Jun 21, 2026
Merged

db.atomic() method#757
simonw merged 3 commits into
mainfrom
atomic

Conversation

@simonw

@simonw simonw commented Jun 21, 2026

Copy link
Copy Markdown
Owner

@simonw simonw added the enhancement New feature or request label Jun 21, 2026
@codecov

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.31%. Comparing base (3cc27d6) to head (a65df4c).

Files with missing lines Patch % Lines
sqlite_utils/db.py 97.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #757      +/-   ##
==========================================
- Coverage   95.33%   95.31%   -0.02%     
==========================================
  Files           9        9              
  Lines        3255     3311      +56     
==========================================
+ Hits         3103     3156      +53     
- Misses        152      155       +3     

☔ View full report in Codecov by Harness.
📢 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.

Comment thread sqlite_utils/db.py
Comment on lines +620 to 634
def _executescript(self, sql: str) -> sqlite3.Cursor:
if self.conn.in_transaction:
cursor = self.conn.cursor()
statement = []
for char in sql:
statement.append(char)
statement_sql = "".join(statement).strip()
if statement_sql and sqlite3.complete_statement(statement_sql):
cursor.execute(statement_sql)
statement = []
statement_sql = "".join(statement).strip()
if statement_sql:
cursor.execute(statement_sql)
return cursor
return self.conn.executescript(sql)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This is the workaround for the problem described here:

To make it clearer why we are avoiding executescript()
@simonw

simonw commented Jun 21, 2026

Copy link
Copy Markdown
Owner Author

I'm testing this branch against various existing projects using this pattern:

PYTHONPATH=/Users/simon/Dropbox/dev/sqlite-utils uv run pytest

Using uv run --with-editable ~/dev/sqlite-utils pytest didn't work because the pinned dependency for the project over-rode the --with-editable.

@simonw simonw marked this pull request as ready for review June 21, 2026 17:41
@simonw simonw merged commit 6729ea3 into main Jun 21, 2026
106 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant