LibraryDatabase2 is obsolete. It works with the new database introduced in V4 because Kovid supplied a "legacy" replacement.
For all new code it is best to use something like this:
Code:
def init_cache(library_path):
from calibre.db.backend import DB
from calibre.db.cache import Cache
backend = DB(library_path) # other named parameters as needed
cache = Cache(backend)
cache.init()
return cache
Use the methods in Cache.
For older code that uses methods in LibraryDatabase2, use something like this:
Code:
from calibre.db.legacy import LibraryDatabase
db = LibraryDatabase(library_path) # other named parameters as needed
In this case the methods in "Cache" are available via db.new_api.
I think the new_api attribute might be available in LibraryDatabase2 through some sort of monkeypatching, but I am not sure of that.