Skip to content

Temporary/throwaway PR to recheck that the resource warning for DB reuse is still active with current version #131

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

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions things/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sqlite3
from textwrap import dedent
from typing import Optional, Union
import weakref


# --------------------------------------------------
Expand Down Expand Up @@ -186,6 +187,7 @@ def __init__(self, filepath=None, print_sql=False):
# See: https://sqlite.org/uri.html#recognized_query_parameters
uri = f"file:{self.filepath}?mode=ro"
self.connection = sqlite3.connect(uri, uri=True) # pylint: disable=E1101
self._finalizer = weakref.finalize(self, self._close_connection)

# Test for migrated database in Things 3.15.16+
# --------------------------------
Expand Down Expand Up @@ -510,6 +512,10 @@ def execute_query(self, sql_query, parameters=(), row_factory=None):

return cursor.fetchall()

def _close_connection(self):
"""Close the database connection."""
self.connection.close()


# Helper functions

Expand Down