mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-08 15:04:05 +08:00
1 line
9.4 KiB
HTML
1 line
9.4 KiB
HTML
<div class="body" role="main"><div class="section" id="data-persistence"><h1><span class="yiyi-st" id="yiyi-9">12.</span><span class="yiyi-st" id="yiyi-10">数据持久性</span></h1><p><span class="yiyi-st" id="yiyi-11">本章中描述的模块支持以永久形式将Python数据存储在磁盘上。</span><span class="yiyi-st" id="yiyi-12"><a class="reference internal" href="pickle.html#module-pickle" title="pickle: Convert Python objects to streams of bytes and back."><code class="xref py py-mod docutils literal"><span class="pre">pickle</span></code></a>和<a class="reference internal" href="marshal.html#module-marshal" title="marshal: Convert Python objects to streams of bytes and back (with different constraints)."><code class="xref py py-mod docutils literal"><span class="pre">marshal</span></code></a>模块可以将许多Python数据类型转换为字节流,然后从字节重新创建对象。</span><span class="yiyi-st" id="yiyi-13">各种DBM相关模块支持一系列基于哈希的文件格式,用于存储字符串到其他字符串的映射。</span></p><p><span class="yiyi-st" id="yiyi-14">本章中描述的模块列表是:</span></p><div class="toctree-wrapper compound"><ul><li class="toctree-l1"><span class="yiyi-st" id="yiyi-28"><a class="reference internal" href="pickle.html">12.1. <code class="docutils literal"><span class="pre">pickle</span></code> - Python对象序列化</a></span><ul><li class="toctree-l2"><span class="yiyi-st" id="yiyi-17"><a class="reference internal" href="pickle.html#relationship-to-other-python-modules">12.1.1.与其他Python模块的关系</a></span><ul><li class="toctree-l3"><span class="yiyi-st" id="yiyi-15"><a class="reference internal" href="pickle.html#comparison-with-marshal">12.1.1.1.与<code class="docutils literal"><span class="pre">marshal</span></code></a>的比较</span></li><li class="toctree-l3"><span class="yiyi-st" id="yiyi-16"><a class="reference internal" href="pickle.html#comparison-with-json">12.1.1.2.与<code class="docutils literal"><span class="pre">json</span></code></a>的比较</span></li></ul></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-18"><a class="reference internal" href="pickle.html#data-stream-format">12.1.2.数据流格式</a></span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-19"><a class="reference internal" href="pickle.html#module-interface">12.1.3.模块接口</a></span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-20"><a class="reference internal" href="pickle.html#what-can-be-pickled-and-unpickled">12.1.4.什么可以腌制和取消腌制?</a></span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-24"><a class="reference internal" href="pickle.html#pickling-class-instances">12.1.5. Pickling类实例</a></span><ul><li class="toctree-l3"><span class="yiyi-st" id="yiyi-21"><a class="reference internal" href="pickle.html#persistence-of-external-objects">12.1.5.1.外部对象的持久性</a></span></li><li class="toctree-l3"><span class="yiyi-st" id="yiyi-22"><a class="reference internal" href="pickle.html#dispatch-tables">12.1.5.2.调度表</a></span></li><li class="toctree-l3"><span class="yiyi-st" id="yiyi-23"><a class="reference internal" href="pickle.html#handling-stateful-objects">12.1.5.3.处理状态对象</a></span></li></ul></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-25"><a class="reference internal" href="pickle.html#restricting-globals">12.1.6.限制全局</a></span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-26"><a class="reference internal" href="pickle.html#performance">12.1.7.性能</a></span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-27"><a class="reference internal" href="pickle.html#examples">12.1.8.示例</a></span></li></ul></li><li class="toctree-l1"><span class="yiyi-st" id="yiyi-30"><a class="reference internal" href="copyreg.html">12.2. <code class="docutils literal"><span class="pre">copyreg</span></code> - 注册<code class="docutils literal"><span class="pre">pickle</span></code>支持功能</a></span><ul><li class="toctree-l2"><span class="yiyi-st" id="yiyi-29"><a class="reference internal" href="copyreg.html#example">12.2.1.示例</a></span></li></ul></li><li class="toctree-l1"><span class="yiyi-st" id="yiyi-33"><a class="reference internal" href="shelve.html">12.3. <code class="docutils literal"><span class="pre">shelve</span></code> - Python对象持久性</a></span><ul><li class="toctree-l2"><span class="yiyi-st" id="yiyi-31"><a class="reference internal" href="shelve.html#restrictions">12.3.1.限制</a></span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-32"><a class="reference internal" href="shelve.html#example">12.3.2.示例</a></span></li></ul></li><li class="toctree-l1"><span class="yiyi-st" id="yiyi-34"><a class="reference internal" href="marshal.html">12.4. <code class="docutils literal"><span class="pre">marshal</span></code> - 内部Python对象序列化</a></span></li><li class="toctree-l1"><span class="yiyi-st" id="yiyi-38"><a class="reference internal" href="dbm.html">12.5. <code class="docutils literal"><span class="pre">dbm</span></code> - 与Unix“数据库”的接口</a></span><ul><li class="toctree-l2"><span class="yiyi-st" id="yiyi-35"><a class="reference internal" href="dbm.html#module-dbm.gnu">12.5.1. <code class="docutils literal"><span class="pre">dbm.gnu</span></code> - GNU对dbm</a>的重新解释</span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-36"><a class="reference internal" href="dbm.html#module-dbm.ndbm">12.5.2. <code class="docutils literal"><span class="pre">dbm.ndbm</span></code> - 基于ndbm</a>的接口</span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-37"><a class="reference internal" href="dbm.html#module-dbm.dumb">12.5.3. <code class="docutils literal"><span class="pre">dbm.dumb</span></code> - 便携式DBM实施</a></span></li></ul></li><li class="toctree-l1"><span class="yiyi-st" id="yiyi-57"><a class="reference internal" href="sqlite3.html">12.6. <code class="docutils literal"><span class="pre">sqlite3</span></code> - SQLite数据库的DB-API 2.0接口</a></span><ul><li class="toctree-l2"><span class="yiyi-st" id="yiyi-39"><a class="reference internal" href="sqlite3.html#module-functions-and-constants">12.6.1.模块函数和常数</a></span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-40"><a class="reference internal" href="sqlite3.html#connection-objects">12.6.2.连接对象</a></span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-41"><a class="reference internal" href="sqlite3.html#cursor-objects">12.6.3.光标对象</a></span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-42"><a class="reference internal" href="sqlite3.html#row-objects">12.6.4.行对象</a></span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-49"><a class="reference internal" href="sqlite3.html#sqlite-and-python-types">12.6.5. SQLite和Python类型</a></span><ul><li class="toctree-l3"><span class="yiyi-st" id="yiyi-43"><a class="reference internal" href="sqlite3.html#introduction">12.6.5.1.简介</a></span></li><li class="toctree-l3"><span class="yiyi-st" id="yiyi-46"><a class="reference internal" href="sqlite3.html#using-adapters-to-store-additional-python-types-in-sqlite-databases">12.6.5.2.使用适配器在SQLite数据库中存储其他Python类型</a></span><ul><li class="toctree-l4"><span class="yiyi-st" id="yiyi-44"><a class="reference internal" href="sqlite3.html#letting-your-object-adapt-itself">12.6.5.2.1.让你的对象适应自己</a></span></li><li class="toctree-l4"><span class="yiyi-st" id="yiyi-45"><a class="reference internal" href="sqlite3.html#registering-an-adapter-callable">12.6.5.2.2.注册适配器可调用</a></span></li></ul></li><li class="toctree-l3"><span class="yiyi-st" id="yiyi-47"><a class="reference internal" href="sqlite3.html#converting-sqlite-values-to-custom-python-types">12.6.5.3.将SQLite值转换为自定义Python类型</a></span></li><li class="toctree-l3"><span class="yiyi-st" id="yiyi-48"><a class="reference internal" href="sqlite3.html#default-adapters-and-converters">12.6.5.4.默认适配器和转换器</a></span></li></ul></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-50"><a class="reference internal" href="sqlite3.html#controlling-transactions">12.6.6.控制事务</a></span></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-54"><a class="reference internal" href="sqlite3.html#using-sqlite3-efficiently">12.6.7.有效地使用<code class="docutils literal"><span class="pre">sqlite3</span></code></a></span><ul><li class="toctree-l3"><span class="yiyi-st" id="yiyi-51"><a class="reference internal" href="sqlite3.html#using-shortcut-methods">12.6.7.1.使用快捷方式</a></span></li><li class="toctree-l3"><span class="yiyi-st" id="yiyi-52"><a class="reference internal" href="sqlite3.html#accessing-columns-by-name-instead-of-by-index">12.6.7.2.按名称而不是按索引</a>访问列</span></li><li class="toctree-l3"><span class="yiyi-st" id="yiyi-53"><a class="reference internal" href="sqlite3.html#using-the-connection-as-a-context-manager">12.6.7.3.将连接用作上下文管理器</a></span></li></ul></li><li class="toctree-l2"><span class="yiyi-st" id="yiyi-56"><a class="reference internal" href="sqlite3.html#common-issues">12.6.8.常见问题</a></span><ul><li class="toctree-l3"><span class="yiyi-st" id="yiyi-55"><a class="reference internal" href="sqlite3.html#multithreading">12.6.8.1.多线程</a></span></li></ul></li></ul></li></ul></div></div></div> |