Python – Shelve module. Write data to disk in dictionary format.

#Create the file where the data will be created. Also enable writeback.
shelf = shelve.open("myshelf.db", writeback=True)

shelf['server1'] = {'Hostname':'Server1', 'RAM':128}
shelf.sync()
print(shelf['server1']['Hostname'])
Share Button