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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1745040964, '3.22.66.60', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/standard-library/shelve(70): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78