Search notes:

Python standard library: shelve

shelve provides a dictionary-like which allows to persist any object that can also be handled by pickle.
import shelve

db = shelve.open('test') # creates test.db

db['key-1'] = 'xyz'
db['key-2'] = [1, 2, 3]

db['key-1'] = {'num': 42}

#
# db[…] returns a copy, not a reference. Therefore
# the following statment does not change the content
# of the db:
#
db['key-1']['txt'] = 'Hello world'

db.close()
Github repository about-python, path: /standard-library/shelve/create-db.py
import shelve

db = shelve.open('test')

for key in db.keys():
    print(key + ': ' + str(db[key]))
Github repository about-python, path: /standard-library/shelve/read-db.py

See also

Other standard library modules, such as

Index