数据持久化
**********

本章中描述的模块支持在磁盘上以持久形式存储 Python 数据。 "pickle" 和
"marshal" 模块可以将许多 Python 数据类型转换为字节流，然后从字节中重新
创建对象。 各种与 DBM 相关的模块支持一系列基于散列的文件格式，这些格式
存储字符串到其他字符串的映射。

本章中描述的模块列表是：

* "pickle" --- Python 对象序列化

  * 与其他 Python 模块间的关系

    * 与 "marshal" 间的关系

    * 与 "json" 模块的比较

  * 数据流格式

  * 模块接口

    * "HIGHEST_PROTOCOL"

    * "DEFAULT_PROTOCOL"

    * "dump()"

    * "dumps()"

    * "load()"

    * "loads()"

    * "PickleError"

    * "PicklingError"

    * "UnpicklingError"

    * "Pickler"

      * "dump()"

      * "persistent_id()"

      * "dispatch_table"

      * "reducer_override()"

      * "fast"

    * "Unpickler"

      * "load()"

      * "persistent_load()"

      * "find_class()"

    * "PickleBuffer"

      * "raw()"

      * "release()"

  * 可以被封存/解封的对象

  * 封存类实例

    * "__getnewargs_ex__()"

    * "__getnewargs__()"

    * "__getstate__()"

    * "__setstate__()"

    * "__reduce__()"

    * "__reduce_ex__()"

    * 持久化外部对象

    * Dispatch 表

    * 处理有状态的对象

  * 类型，函数和其他对象的自定义归约

  * 外部缓冲区

    * 提供方 API

    * 使用方 API

    * 示例

  * 限制全局变量

  * 性能

  * 例子

* "copyreg" --- 注册 "pickle" 支持函数

  * "constructor()"

  * "pickle()"

  * 示例

* "shelve" --- Python 对象持久化

  * "open()"

  * "sync()"

  * "close()"

  * 限制

    * "Shelf"

    * "BsdDbShelf"

    * "DbfilenameShelf"

  * 示例

* "marshal" --- 内部 Python 对象序列化

  * "dump()"

  * "load()"

  * "dumps()"

  * "loads()"

  * "version"

* "dbm" --- Unix "数据库" 接口

  * "error"

  * "whichdb()"

  * "open()"

  * "dbm.sqlite3" --- 针对 dbm 的 SQLite 后端

    * "open()"

  * "dbm.gnu" --- GNU 数据库管理器

    * "error"

    * "open()"

      * "open_flags"

      * "firstkey()"

      * "nextkey()"

      * "reorganize()"

      * "sync()"

      * "close()"

      * "clear()"

  * "dbm.ndbm" --- 新数据库管理器

    * "error"

    * "library"

    * "open()"

      * "close()"

      * "clear()"

  * "dbm.dumb" --- 便携式 DBM 实现

    * "error"

    * "open()"

      * "sync()"

      * "close()"

* "sqlite3" --- SQLite 数据库的 DB-API 2.0 接口

  * 教程

  * 参考

    * 模块函数

      * "connect()"

      * "complete_statement()"

      * "enable_callback_tracebacks()"

      * "register_adapter()"

      * "register_converter()"

    * 模块常量

      * "LEGACY_TRANSACTION_CONTROL"

      * "PARSE_COLNAMES"

      * "PARSE_DECLTYPES"

      * "SQLITE_OK"

      * "SQLITE_DENY"

      * "SQLITE_IGNORE"

      * "apilevel"

      * "paramstyle"

      * "sqlite_version"

      * "sqlite_version_info"

      * "threadsafety"

      * "SQLITE_DBCONFIG_DEFENSIVE"

      * "SQLITE_DBCONFIG_DQS_DDL"

      * "SQLITE_DBCONFIG_DQS_DML"

      * "SQLITE_DBCONFIG_ENABLE_FKEY"

      * "SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER"

      * "SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION"

      * "SQLITE_DBCONFIG_ENABLE_QPSG"

      * "SQLITE_DBCONFIG_ENABLE_TRIGGER"

      * "SQLITE_DBCONFIG_ENABLE_VIEW"

      * "SQLITE_DBCONFIG_LEGACY_ALTER_TABLE"

      * "SQLITE_DBCONFIG_LEGACY_FILE_FORMAT"

      * "SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE"

      * "SQLITE_DBCONFIG_RESET_DATABASE"

      * "SQLITE_DBCONFIG_TRIGGER_EQP"

      * "SQLITE_DBCONFIG_TRUSTED_SCHEMA"

      * "SQLITE_DBCONFIG_WRITABLE_SCHEMA"

    * 连接对象

      * "Connection"

        * "cursor()"

        * "blobopen()"

        * "commit()"

        * "rollback()"

        * "close()"

        * "execute()"

        * "executemany()"

        * "executescript()"

        * "create_function()"

        * "create_aggregate()"

        * "create_window_function()"

        * "create_collation()"

        * "interrupt()"

        * "set_authorizer()"

        * "set_progress_handler()"

        * "set_trace_callback()"

        * "enable_load_extension()"

        * "load_extension()"

        * "iterdump()"

        * "backup()"

        * "getlimit()"

        * "setlimit()"

        * "getconfig()"

        * "setconfig()"

        * "serialize()"

        * "deserialize()"

        * "autocommit"

        * "in_transaction"

        * "isolation_level"

        * "row_factory"

        * "text_factory"

        * "total_changes"

    * 游标对象

      * "Cursor"

        * "execute()"

        * "executemany()"

        * "executescript()"

        * "fetchone()"

        * "fetchmany()"

        * "fetchall()"

        * "close()"

        * "setinputsizes()"

        * "setoutputsize()"

        * "arraysize"

        * "connection"

        * "description"

        * "lastrowid"

        * "rowcount"

        * "row_factory"

    * Row 对象

      * "Row"

        * "keys()"

    * Blob 对象

      * "Blob"

        * "close()"

        * "read()"

        * "write()"

        * "tell()"

        * "seek()"

    * PrepareProtocol 对象

      * "PrepareProtocol"

    * 异常

      * "Warning"

      * "Error"

        * "sqlite_errorcode"

        * "sqlite_errorname"

      * "InterfaceError"

      * "DatabaseError"

      * "DataError"

      * "OperationalError"

      * "IntegrityError"

      * "InternalError"

      * "ProgrammingError"

      * "NotSupportedError"

    * SQLite 与 Python 类型

    * 默认适配器和转换器（已弃用）

    * 命令行接口

  * 常用方案指引

    * 如何在 SQL 查询中使用占位符来绑定值

    * 如何将自定义 Python 类型适配到 SQLite 值

      * 如何编写可适配对象

      * 如何注册适配器可调用对象

    * 如何将 SQLite 值转换为自定义 Python 类型

    * 适配器和转换器范例程序

    * 如何使用连接快捷方法

    * 如何使用连接上下文管理器

    * 如何使用 SQLite URI

    * 如何创建并使用行工厂对象

    * 如何处理非 UTF-8 文本编码格式

  * 说明

    * 事务控制

      * 通过 "autocommit" 属性进行事务控制

      * 通过 "isolation_level" 属性进行事务控制
