### Navigation

- index
- modules |
- next |
- previous |
- Python v2.6.2 documentation »
- The Python Standard Library »

# 12. Data Persistence

The modules described in this chapter support storing Python data in a persistent form on disk. The `pickle` and `marshal` modules can turn many Python data types into a stream of bytes and then recreate the objects from the bytes. The various DBM-related modules support a family of hash-based file formats that store a mapping of strings to other strings. The `bsddb` module also provides such disk-based string-to-string mappings based on hashing, and also supports B-Tree and record-based formats.

The list of modules described in this chapter is:

- 12.1. `pickle` — Python object serialization
  - 12.1.1. Relationship to other Python modules
  - 12.1.2. Data stream format
  - 12.1.3. Usage
  - 12.1.4. What can be pickled and unpickled?
  - 12.1.5. The pickle protocol
    - 12.1.5.1. Pickling and unpickling normal class instances
    - 12.1.5.2. Pickling and unpickling extension types
    - 12.1.5.3. Pickling and unpickling external objects
  - 12.1.6. Subclassing Unpicklers
  - 12.1.7. Example
- 12.2. `cPickle` — A faster `pickle`
- 12.3. `copy_reg` — Register `pickle` support functions
- 12.4. `shelve` — Python object persistence
  - 12.4.1. Restrictions
  - 12.4.2. Example
- 12.5. `marshal` — Internal Python object serialization
- 12.6. `anydbm` — Generic access to DBM-style databases
- 12.7. `whichdb` — Guess which DBM module created a database
- 12.8. `dbm` — Simple “database” interface
- 12.9. `gdbm` — GNU’s reinterpretation of dbm
- 12.10. `dbhash` — DBM-style interface to the BSD database library
  - 12.10.1. Database Objects
- 12.11. `bsddb` — Interface to Berkeley DB library
  - 12.11.1. Hash, BTree and Record Objects
- 12.12. `dumbdbm` — Portable DBM implementation
  - 12.12.1. Dumbdbm Objects
- 12.13. `sqlite3` — DB-API 2.0 interface for SQLite databases
  - 12.13.1. Module functions and constants
  - 12.13.2. Connection Objects
  - 12.13.3. Cursor Objects
  - 12.13.4. Row Objects
  - 12.13.5. SQLite and Python types
    - 12.13.5.1. Introduction
    - 12.13.5.2. Using adapters to store additional Python types in SQLite databases
      - 12.13.5.2.1. Letting your object adapt itself
      - 12.13.5.2.2. Registering an adapter callable
    - 12.13.5.3. Converting SQLite values to custom Python types
    - 12.13.5.4. Default adapters and converters
  - 12.13.6. Controlling Transactions
  - 12.13.7. Using pysqlite efficiently
    - 12.13.7.1. Using shortcut methods
    - 12.13.7.2. Accessing columns by name instead of by index
    - 12.13.7.3. Using the connection as a context manager

### Navigation

- index
- modules |
- next |
- previous |
- Python v2.6.2 documentation »
- The Python Standard Library »