Skip to content

Conversation

@yunzheng
Copy link
Member

  • SqliteReader was missing a close() method
  • sqlite3.Connection as a context manager does NOT close the connection it only commits or rolls back the transaction.

resolves #209

- SqliteReader was missing a close() method
- sqlite3.Connection as a context manager does NOT close the connection
it only commits or rolls back the transaction.
@yunzheng yunzheng force-pushed the fix-sqlite3-resourcewarning branch from 3d286ac to 1650e5c Compare January 25, 2026 21:42
@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.35%. Comparing base (c3f8cd8) to head (1650e5c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #210      +/-   ##
==========================================
+ Coverage   83.33%   83.35%   +0.01%     
==========================================
  Files          35       35              
  Lines        3714     3718       +4     
==========================================
+ Hits         3095     3099       +4     
  Misses        619      619              
Flag Coverage Δ
unittests 83.35% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Copy link

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 pull request fixes ResourceWarning about unclosed database connections in Python 3.13+ by implementing proper resource cleanup for SQLite connections.

Changes:

  • Added a close() method to SqliteReader to properly close database connections
  • Updated test cases to use closing() context manager for explicit connection cleanup
  • Added explicit commit() calls in tests where data persistence is required

Reviewed changes

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

File Description
flow/record/adapter/sqlite.py Implements close() method in SqliteReader to properly close database connections
tests/adapter/test_sqlite_duckdb.py Updates all test cases to use closing() wrapper and adds explicit commit() calls for proper transaction handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

ResourceWarning: unclosed database in sqlite3.Connection

2 participants