def METHOD_NAME(self) -> ContextManager[sqlite3.Connection]:
    """
    A context manager opens a connection to the database and handles the transaction.
    The opened connection is stored inside the ProcessManager instance. It allows to recursively
    the context manager, the inner invocation re-uses the connection opened in the outer context manager.
    In the case of a sqlite3.DatabaseError exception, the database is deleted to handle possible database
    corruption. The database content is not critical for Tribler's functioning, so its loss is tolerable.
    """
    if self.connection is not None:
        yield self.connection
        return
    connection = None
    try:
        self.connection = connection = sqlite3.METHOD_NAME(str(self.db_filepath))
        try:
            connection.execute('BEGIN EXCLUSIVE TRANSACTION')
            connection.execute(sql_scripts.CREATE_TABLES)
            connection.execute(sql_scripts.DELETE_OLD_RECORDS)
            yield connection
        finally:
            self.connection = None
        connection.execute('COMMIT')
        connection.close()
    except Exception as e:
        logger.exception(f'{e.__class__.__name__}: {e}')
        if connection:
            connection.close()
        if isinstance(e, sqlite3.DatabaseError):
            self.db_filepath.unlink(missing_ok=True)
        raise