Since it's not much longer, though this would benefit from a more complete test script:
Code:
# Run with calibre-debug -e calibre_filler.py
import calibre.library
LIBRARY = "calibre/andy"
calibre_db = calibre.library.db(LIBRARY).new_api
# calibre_books = get_calibre_books()
metadata = calibre_db.get_metadata(291)
stars = metadata.get_user_metadata("#stars", True)
stars["#value#"] = 7 # values are 0 to 10
read = metadata.get_user_metadata("#read", True)
read["#value#"] = True
print(f" Update metadata from [{stars['#value#']}] [{read['#value#']}]")
metadata.set_user_metadata("#stars", stars)
metadata.set_user_metadata("#read", read)
It reads the values fine but doesn't store them in the database. Is there a "write" command of some kind I'm not aware of?