# 資料持久性 (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.

本章節所描述的模組列表為：

- `pickle` --- Python 物件序列化
  - 和其他 Python 模組的關係
    - 和 `marshal` 的比較
    - 和 `json` 的比較
  - Data stream format
  - 模組介面
  - What can be pickled and unpickled?
  - Pickling Class Instances
    - Persistence of External Objects
    - Dispatch Tables
    - Handling Stateful Objects
  - Custom Reduction for Types, Functions, and Other Objects
  - Out-of-band Buffers
    - Provider API
    - Consumer API
    - 範例
  - Restricting Globals
  - Performance
  - 範例
- `copyreg` --- 註冊 `pickle` 支援函式
  - 範例
- `shelve` --- Python object persistence
  - Restrictions
  - 範例
- `marshal` --- 内部 Python 物件序列化
- `dbm` --- Unix "databases" 的介面
  - `dbm.gnu` --- GNU 資料庫管理器
  - `dbm.ndbm` --- 新資料庫管理器
  - `dbm.dumb` --- 可攜式 DBM 實作
- `sqlite3` --- SQLite 資料庫的 DB-API 2.0 介面
  - 教學
  - Reference
    - Module functions
    - Module constants
    - Connection 物件
    - Cursor 物件
    - Row 物件
    - Blob 物件
    - PrepareProtocol 物件
    - 例外
    - SQLite and Python types
    - Default adapters and converters (deprecated)
    - 命令列介面
  - How-to guides
    - How to use placeholders to bind values in SQL queries
    - How to adapt custom Python types to SQLite values
      - How to write adaptable objects
      - How to register adapter callables
    - How to convert SQLite values to custom Python types
    - Adapter and converter recipes
    - How to use connection shortcut methods
    - How to use the connection context manager
    - How to work with SQLite URIs
    - How to create and use row factories
    - How to handle non-UTF-8 text encodings
  - 解釋
    - Transaction control
      - Transaction control via the `autocommit` attribute
      - Transaction control via the `isolation_level` attribute