### Navigation

- index
- modules |
- next |
- previous |
- Python v3.2.3 documentation »
- The Python Standard Library »

# 11. 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 list of modules described in this chapter is:

- 11.1. `pickle` — Python object serialization
  - 11.1.1. Relationship to other Python modules
  - 11.1.2. Data stream format
  - 11.1.3. Module Interface
  - 11.1.4. What can be pickled and unpickled?
  - 11.1.5. Pickling Class Instances
    - 11.1.5.1. Persistence of External Objects
    - 11.1.5.2. Handling Stateful Objects
  - 11.1.6. Restricting Globals
  - 11.1.7. Examples
- 11.2. `copyreg` — Register `pickle` support functions
- 11.3. `shelve` — Python object persistence
  - 11.3.1. Restrictions
  - 11.3.2. Example
- 11.4. `marshal` — Internal Python object serialization
- 11.5. `dbm` — Interfaces to Unix “databases”
  - 11.5.1. `dbm.gnu` — GNU’s reinterpretation of dbm
  - 11.5.2. `dbm.ndbm` — Interface based on ndbm
  - 11.5.3. `dbm.dumb` — Portable DBM implementation
- 11.6. `sqlite3` — DB-API 2.0 interface for SQLite databases
  - 11.6.1. Module functions and constants
  - 11.6.2. Connection Objects
  - 11.6.3. Cursor Objects
  - 11.6.4. Row Objects
  - 11.6.5. SQLite and Python types
    - 11.6.5.1. Introduction
    - 11.6.5.2. Using adapters to store additional Python types in SQLite databases
      - 11.6.5.2.1. Letting your object adapt itself
      - 11.6.5.2.2. Registering an adapter callable
    - 11.6.5.3. Converting SQLite values to custom Python types
    - 11.6.5.4. Default adapters and converters
  - 11.6.6. Controlling Transactions
  - 11.6.7. Using `sqlite3` efficiently
    - 11.6.7.1. Using shortcut methods
    - 11.6.7.2. Accessing columns by name instead of by index
    - 11.6.7.3. Using the connection as a context manager
  - 11.6.8. Common issues
    - 11.6.8.1. Multithreading

### Navigation

- index
- modules |
- next |
- previous |
- Python v3.2.3 documentation »
- The Python Standard Library »