The standard library includes a variety of modules for persisting data. The most common pattern for storing data from Python objects for reuse is to serialize them with pickle and then either write them directly to a file or store them using one of the many key-value pair database formats available with the dbm API. If you don’t care about the underlying dbm format, the best persistence interface is provided by shelve. If you do care, you can use one of the other dbm-based modules directly.
- anydbm – Access to DBM-style databases
- dbhash – DBM-style API for the BSD database library
- dbm – Simple database interface
- dumbdbm – Portable DBM Implementation
- gdbm – GNU’s version of the dbm library
- pickle and cPickle – Python object serialization
- shelve – Persistent storage of arbitrary Python objects
- whichdb – Identify DBM-style database formats
- sqlite3 – Embedded Relational Database
For serializing over the web, the json module may be a better choice since its format is more portable.