/usr/share/doc/python-apsw/html/backup.html is in python-apsw-doc 3.8.2-r1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Backup — APSW 3.8.2-r1 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '3.8.2-r1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="copyright" title="Copyright" href="copyright.html" />
<link rel="top" title="APSW 3.8.2-r1 documentation" href="index.html" />
<link rel="next" title="Virtual Tables" href="vtable.html" />
<link rel="prev" title="Blob Input/Output" href="blob.html" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-26815066-1']);
_gaq.push(['_trackPageview']);
</script>
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="vtable.html" title="Virtual Tables"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="blob.html" title="Blob Input/Output"
accesskey="P">previous</a> |</li>
<li><a href="index.html">APSW 3.8.2-r1 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="backup">
<span id="id1"></span><h1>Backup<a class="headerlink" href="#backup" title="Permalink to this headline">¶</a></h1>
<p>A backup object encapsulates copying one database to another. You
call <a class="reference internal" href="connection.html#apsw.Connection.backup" title="apsw.Connection.backup"><tt class="xref py py-meth docutils literal"><span class="pre">Connection.backup()</span></tt></a> on the destination database to get the
backup object. Call <a class="reference internal" href="#apsw.backup.step" title="apsw.backup.step"><tt class="xref py py-meth docutils literal"><span class="pre">step()</span></tt></a> to copy some pages
repeatedly dealing with errors as appropriate. Finally
<a class="reference internal" href="#apsw.backup.finish" title="apsw.backup.finish"><tt class="xref py py-meth docutils literal"><span class="pre">finish()</span></tt></a> cleans up committing or rolling back and
releasing locks.</p>
<p>Here is an example usage using the <strong>with</strong> statement to ensure
<a class="reference internal" href="#apsw.backup.finish" title="apsw.backup.finish"><tt class="xref py py-meth docutils literal"><span class="pre">finish()</span></tt></a> is called:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># copies source.main into db</span>
<span class="k">with</span> <span class="n">db</span><span class="o">.</span><span class="n">backup</span><span class="p">(</span><span class="s">"main"</span><span class="p">,</span> <span class="n">source</span><span class="p">,</span> <span class="s">"main"</span><span class="p">)</span> <span class="k">as</span> <span class="n">b</span><span class="p">:</span>
<span class="k">while</span> <span class="ow">not</span> <span class="n">b</span><span class="o">.</span><span class="n">done</span><span class="p">:</span>
<span class="n">b</span><span class="o">.</span><span class="n">step</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="k">print</span> <span class="n">b</span><span class="o">.</span><span class="n">remaining</span><span class="p">,</span> <span class="n">b</span><span class="o">.</span><span class="n">pagecount</span><span class="p">,</span> <span class="s">"</span><span class="se">\r</span><span class="s">"</span><span class="p">,</span>
</pre></div>
</div>
<p>If you are not using <strong>with</strong> then you’ll need to ensure
<a class="reference internal" href="#apsw.backup.finish" title="apsw.backup.finish"><tt class="xref py py-meth docutils literal"><span class="pre">finish()</span></tt></a> is called:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># copies source.main into db</span>
<span class="n">b</span><span class="o">=</span><span class="n">db</span><span class="o">.</span><span class="n">backup</span><span class="p">(</span><span class="s">"main"</span><span class="p">,</span> <span class="n">source</span><span class="p">,</span> <span class="s">"main"</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">while</span> <span class="ow">not</span> <span class="n">b</span><span class="o">.</span><span class="n">done</span><span class="p">:</span>
<span class="n">b</span><span class="o">.</span><span class="n">step</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="k">print</span> <span class="n">b</span><span class="o">.</span><span class="n">remaining</span><span class="p">,</span> <span class="n">b</span><span class="o">.</span><span class="n">pagecount</span><span class="p">,</span> <span class="s">"</span><span class="se">\r</span><span class="s">"</span><span class="p">,</span>
<span class="k">finally</span><span class="p">:</span>
<span class="n">b</span><span class="o">.</span><span class="n">finish</span><span class="p">()</span>
</pre></div>
</div>
<div class="section" id="important-details">
<h2>Important details<a class="headerlink" href="#important-details" title="Permalink to this headline">¶</a></h2>
<p>The database is copied page by page. This means that there is not a
round trip via SQL. All pages are copied including free ones.</p>
<p>The destination database is locked during the copy. You will get a
<a class="reference internal" href="exceptions.html#apsw.ThreadingViolationError" title="apsw.ThreadingViolationError"><tt class="xref py py-exc docutils literal"><span class="pre">ThreadingViolationError</span></tt></a> if you attempt to use it.</p>
</div>
<div class="section" id="backup-class">
<h2>backup class<a class="headerlink" href="#backup-class" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="apsw.backup">
<em class="property">class </em><tt class="descname">backup</tt><a class="headerlink" href="#apsw.backup" title="Permalink to this definition">¶</a></dt>
<dd><p>You create a backup instance by calling <a class="reference internal" href="connection.html#apsw.Connection.backup" title="apsw.Connection.backup"><tt class="xref py py-meth docutils literal"><span class="pre">Connection.backup()</span></tt></a>.</p>
</dd></dl>
<dl class="method">
<dt id="apsw.backup.__enter__">
<tt class="descclassname">backup.</tt><tt class="descname">__enter__</tt><big>(</big><big>)</big> → self<a class="headerlink" href="#apsw.backup.__enter__" title="Permalink to this definition">¶</a></dt>
<dd><p>You can use the backup object as a <a class="reference external" href="http://docs.python.org/reference/datamodel.html#with-statement-context-managers">context manager</a>
as defined in <span class="target" id="index-0"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0343"><strong>PEP 0343</strong></a>. The <a class="reference internal" href="#apsw.backup.__exit__" title="apsw.backup.__exit__"><tt class="xref py py-meth docutils literal"><span class="pre">__exit__()</span></tt></a> method ensures that backup
is <a class="reference internal" href="#apsw.backup.finish" title="apsw.backup.finish"><tt class="xref py py-meth docutils literal"><span class="pre">finished</span></tt></a>.</p>
</dd></dl>
<dl class="method">
<dt id="apsw.backup.__exit__">
<tt class="descclassname">backup.</tt><tt class="descname">__exit__</tt><big>(</big><big>)</big> → False<a class="headerlink" href="#apsw.backup.__exit__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implements context manager in conjunction with <a class="reference internal" href="#apsw.backup.__enter__" title="apsw.backup.__enter__"><tt class="xref py py-meth docutils literal"><span class="pre">__enter__()</span></tt></a> ensuring
that the copy is <a class="reference internal" href="#apsw.backup.finish" title="apsw.backup.finish"><tt class="xref py py-meth docutils literal"><span class="pre">finished</span></tt></a>.</p>
</dd></dl>
<dl class="method">
<dt id="apsw.backup.close">
<tt class="descclassname">backup.</tt><tt class="descname">close</tt><big>(</big><span class="optional">[</span><em>force=False</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#apsw.backup.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Does the same thing as <a class="reference internal" href="#apsw.backup.finish" title="apsw.backup.finish"><tt class="xref py py-meth docutils literal"><span class="pre">finish()</span></tt></a>. This extra api is
provided to give the same api as other APSW objects such as
<a class="reference internal" href="connection.html#apsw.Connection.close" title="apsw.Connection.close"><tt class="xref py py-meth docutils literal"><span class="pre">Connection.close()</span></tt></a>, <a class="reference internal" href="blob.html#apsw.blob.close" title="apsw.blob.close"><tt class="xref py py-meth docutils literal"><span class="pre">blob.close()</span></tt></a> and
<a class="reference internal" href="cursor.html#apsw.Cursor.close" title="apsw.Cursor.close"><tt class="xref py py-meth docutils literal"><span class="pre">Cursor.close()</span></tt></a>. It is safe to call this method multiple
times.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>force</strong> – If true then any exceptions are ignored.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="apsw.backup.done">
<tt class="descclassname">backup.</tt><tt class="descname">done</tt><a class="headerlink" href="#apsw.backup.done" title="Permalink to this definition">¶</a></dt>
<dd><p>A boolean that is True if the copy completed in the last call to <a class="reference internal" href="#apsw.backup.step" title="apsw.backup.step"><tt class="xref py py-meth docutils literal"><span class="pre">step()</span></tt></a>.</p>
</dd></dl>
<span class="target" id="index-1"></span><dl class="method">
<dt id="apsw.backup.finish">
<tt class="descclassname">backup.</tt><tt class="descname">finish</tt><big>(</big><big>)</big><a class="headerlink" href="#apsw.backup.finish" title="Permalink to this definition">¶</a></dt>
<dd><p>Completes the copy process. If all pages have been copied then the
transaction is committed on the destination database, otherwise it
is rolled back. This method must be called for your backup to take
effect. The backup object will always be finished even if there is
an exception. It is safe to call this method multiple times.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/backup_finish.html#sqlite3backupf.html">sqlite3_backup_finish</a></p>
</dd></dl>
<span class="target" id="index-2"></span><dl class="attribute">
<dt id="apsw.backup.pagecount">
<tt class="descclassname">backup.</tt><tt class="descname">pagecount</tt><a class="headerlink" href="#apsw.backup.pagecount" title="Permalink to this definition">¶</a></dt>
<dd><p>Read only. How many pages were in the source database after the last
step. If you haven’t called <a class="reference internal" href="#apsw.backup.step" title="apsw.backup.step"><tt class="xref py py-meth docutils literal"><span class="pre">step()</span></tt></a> or the backup
object has been <a class="reference internal" href="#apsw.backup.finish" title="apsw.backup.finish"><tt class="xref py py-meth docutils literal"><span class="pre">finished</span></tt></a> then zero is
returned.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/backup_finish.html#sqlite3backupf.html">sqlite3_backup_pagecount</a></p>
</dd></dl>
<span class="target" id="index-3"></span><dl class="attribute">
<dt id="apsw.backup.remaining">
<tt class="descclassname">backup.</tt><tt class="descname">remaining</tt><a class="headerlink" href="#apsw.backup.remaining" title="Permalink to this definition">¶</a></dt>
<dd><p>Read only. How many pages were remaining to be copied after the last
step. If you haven’t called <a class="reference internal" href="#apsw.backup.step" title="apsw.backup.step"><tt class="xref py py-meth docutils literal"><span class="pre">step()</span></tt></a> or the backup
object has been <a class="reference internal" href="#apsw.backup.finish" title="apsw.backup.finish"><tt class="xref py py-meth docutils literal"><span class="pre">finished</span></tt></a> then zero is
returned.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/backup_finish.html#sqlite3backupf.html">sqlite3_backup_remaining</a></p>
</dd></dl>
<span class="target" id="index-4"></span><dl class="method">
<dt id="apsw.backup.step">
<tt class="descclassname">backup.</tt><tt class="descname">step</tt><big>(</big><span class="optional">[</span><em>npages=All</em><span class="optional">]</span><big>)</big> → bool<a class="headerlink" href="#apsw.backup.step" title="Permalink to this definition">¶</a></dt>
<dd><p>Copies <em>npages</em> pages from the source to destination database. The source database is locked during the copy so
using smaller values allows other access to the source database. The destination database is always locked until the
backup object is <a class="reference internal" href="#apsw.backup.finish" title="apsw.backup.finish"><tt class="xref py py-meth docutils literal"><span class="pre">finished</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>npages</strong> – How many pages to copy. If the parameter is omitted
or negative then all remaining pages are copied. The default page
size is 1024 bytes (1kb) which can be changed before database
creation using a <a class="reference external" href="https://sqlite.org/pragma.html#modify">pragma</a>.</td>
</tr>
</tbody>
</table>
<p>This method may throw a <a class="reference internal" href="exceptions.html#apsw.BusyError" title="apsw.BusyError"><tt class="xref py py-exc docutils literal"><span class="pre">BusyError</span></tt></a> or <a class="reference internal" href="exceptions.html#apsw.LockedError" title="apsw.LockedError"><tt class="xref py py-exc docutils literal"><span class="pre">LockedError</span></tt></a> if
unable to lock the source database. You can catch those and try
again.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True if this copied the last remaining outstanding pages, else false. This is the same value as <a class="reference internal" href="#apsw.backup.done" title="apsw.backup.done"><tt class="xref py py-attr docutils literal"><span class="pre">done</span></tt></a></td>
</tr>
</tbody>
</table>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/backup_finish.html#sqlite3backupf.html">sqlite3_backup_step</a></p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Backup</a><ul>
<li><a class="reference internal" href="#important-details">Important details</a></li>
<li><a class="reference internal" href="#backup-class">backup class</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="blob.html"
title="previous chapter">Blob Input/Output</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="vtable.html"
title="next chapter">Virtual Tables</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/backup.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="vtable.html" title="Virtual Tables"
>next</a> |</li>
<li class="right" >
<a href="blob.html" title="Blob Input/Output"
>previous</a> |</li>
<li><a href="index.html">APSW 3.8.2-r1 documentation</a> »</li>
</ul>
</div>
<div class="footer">
© <a href="copyright.html">Copyright</a> 2004-2013, Roger Binns <rogerb@rogerbinns.com>.
Last updated on Dec 08, 2013.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
(function() {
var ga = document.createElement('script');
ga.src = ('https:' == document.location.protocol ?
'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
ga.setAttribute('async', 'true');
document.documentElement.firstChild.appendChild(ga);
})();
</script>
</div>
</body>
</html>
|