Expose sqlite transaction via db.new_api

This commit is contained in:
Kovid Goyal 2025-07-09 08:23:15 +05:30
parent d3af35fa6d
commit 7e88bac83a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 12 additions and 0 deletions

View File

@ -1476,6 +1476,12 @@ class DB:
self.user_version = 1 self.user_version = 1
# }}} # }}}
def __enter__(self):
self.conn.__enter__()
def __exit__(self, exc_type, exc_value, tb):
self.conn.__exit__(exc_type, exc_value, tb)
def clone_for_readonly_access(self, dest_dir: str) -> str: def clone_for_readonly_access(self, dest_dir: str) -> str:
dbpath = os.path.abspath(self.conn.db_filename('main')) dbpath = os.path.abspath(self.conn.db_filename('main'))
clone_db_path = os.path.join(dest_dir, os.path.basename(dbpath)) clone_db_path = os.path.join(dest_dir, os.path.basename(dbpath))

View File

@ -294,6 +294,12 @@ class Cache:
def last_modified(self): def last_modified(self):
return self.backend.last_modified() return self.backend.last_modified()
def __enter__(self):
self.backend.__enter__()
def __exit__(self, exc_type, exc_value, tb):
self.backend.__exit__(exc_type, exc_value, tb)
@write_api @write_api
def clear_caches(self, book_ids=None, template_cache=True, search_cache=True): def clear_caches(self, book_ids=None, template_cache=True, search_cache=True):
if template_cache: if template_cache: