Handle mutable objects correctly
masterBecause of Python semantics, sqlitedict cannot detect when a mutable object retrieved from the database has been modified in memory. To save changes to a mutable object, you must explicitly assign the modified object back to the SqliteDict and call .commit().
from sqlitedict import SqliteDict
db = SqliteDict("example.sqlite")
db["colors"] = {"red": (255, 0, 0)}
db.commit()
# Retrieve the object
colors = db["colors"]
# Modify the object in RAM
colors["blue"] = (0, 0, 255)
# IMPORTANT: Re-assign and commit to save changes
db["colors"] = colors
db.commit()
db.close()