This file is indexed.

/usr/share/doc/python-apsw/html/exceptions.html is in python-apsw-doc 3.16.2-r1-2build2.

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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
<!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>Exceptions &#8212; APSW 3.16.2-r1 documentation</title>
    
    <link rel="stylesheet" href="_static/classic.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.16.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="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="copyright" title="Copyright" href="copyright.html" />
    <link rel="top" title="APSW 3.16.2-r1 documentation" href="index.html" />
    <link rel="next" title="Types" href="types.html" />
    <link rel="prev" title="Shell" href="shell.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-26815066-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head>
  <body role="document">
    <div class="related" role="navigation" aria-label="related navigation">
      <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="types.html" title="Types"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="shell.html" title="Shell"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">APSW 3.16.2-r1 documentation</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="exceptions">
<span id="id1"></span><h1>Exceptions<a class="headerlink" href="#exceptions" title="Permalink to this headline"></a></h1>
<p><a class="reference internal" href="#apsw.Error" title="apsw.Error"><code class="xref py py-exc docutils literal"><span class="pre">apsw.Error</span></code></a> is the base for APSW exceptions.</p>
<dl class="exception">
<dt id="apsw.Error">
<em class="property">exception </em><code class="descname">Error</code><a class="headerlink" href="#apsw.Error" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="apsw.Error.result">
<code class="descclassname">Error.</code><code class="descname">result</code><a class="headerlink" href="#apsw.Error.result" title="Permalink to this definition"></a></dt>
<dd><p>For exceptions corresponding to <a class="reference external" href="https://sqlite.org/c3ref/c_abort.html">SQLite error codes</a> codes this attribute
is the numeric error code.</p>
</dd></dl>

<dl class="attribute">
<dt id="apsw.Error.extendedresult">
<code class="descclassname">Error.</code><code class="descname">extendedresult</code><a class="headerlink" href="#apsw.Error.extendedresult" title="Permalink to this definition"></a></dt>
<dd><p>APSW runs with <a class="reference external" href="https://sqlite.org/c3ref/c_ioerr_blocked.html">extended result codes</a> turned on.
This attribute includes the detailed code.</p>
</dd></dl>

<p>As an example, if SQLite issued a read request and the system returned
less data than expected then <a class="reference internal" href="#apsw.Error.result" title="apsw.Error.result"><code class="xref py py-attr docutils literal"><span class="pre">result</span></code></a> would have the value
<code class="xref py py-const docutils literal"><span class="pre">SQLITE_IOERR</span></code> while <a class="reference internal" href="#apsw.Error.extendedresult" title="apsw.Error.extendedresult"><code class="xref py py-attr docutils literal"><span class="pre">extendedresult</span></code></a> would have
the value <code class="xref py py-const docutils literal"><span class="pre">SQLITE_IOERR_SHORT_READ</span></code>.</p>
<div class="section" id="apsw-specific-exceptions">
<h2>APSW specific exceptions<a class="headerlink" href="#apsw-specific-exceptions" title="Permalink to this headline"></a></h2>
<p>The following exceptions happen when APSW detects various problems.</p>
<dl class="exception">
<dt id="apsw.ThreadingViolationError">
<em class="property">exception </em><code class="descname">ThreadingViolationError</code><a class="headerlink" href="#apsw.ThreadingViolationError" title="Permalink to this definition"></a></dt>
<dd><p>You have used an object concurrently in two threads. For example you
may try to use the same cursor in two different threads at the same
time, or tried to close the same connection in two threads at the
same time.</p>
<p>You can also get this exception by using a cursor as an argument to
itself (eg as the input data for <a class="reference internal" href="cursor.html#apsw.Cursor.executemany" title="apsw.Cursor.executemany"><code class="xref py py-meth docutils literal"><span class="pre">Cursor.executemany()</span></code></a>).
Cursors can only be used for one thing at a time.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.ForkingViolationError">
<em class="property">exception </em><code class="descname">ForkingViolationError</code><a class="headerlink" href="#apsw.ForkingViolationError" title="Permalink to this definition"></a></dt>
<dd><p>See <a class="reference internal" href="apsw.html#apsw.fork_checker" title="apsw.fork_checker"><code class="xref py py-meth docutils literal"><span class="pre">apsw.fork_checker()</span></code></a>.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.IncompleteExecutionError">
<em class="property">exception </em><code class="descname">IncompleteExecutionError</code><a class="headerlink" href="#apsw.IncompleteExecutionError" title="Permalink to this definition"></a></dt>
<dd><p>You have tried to start a new SQL execute call before executing all
the previous ones. See the <a class="reference internal" href="execution.html#executionmodel"><span class="std std-ref">execution model</span></a>
for more details.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.ConnectionNotClosedError">
<em class="property">exception </em><code class="descname">ConnectionNotClosedError</code><a class="headerlink" href="#apsw.ConnectionNotClosedError" title="Permalink to this definition"></a></dt>
<dd><p>This exception is no longer generated.  It was required in earlier
releases due to constraints in threading usage with SQLite.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.ConnectionClosedError">
<em class="property">exception </em><code class="descname">ConnectionClosedError</code><a class="headerlink" href="#apsw.ConnectionClosedError" title="Permalink to this definition"></a></dt>
<dd><p>You have called <a class="reference internal" href="connection.html#apsw.Connection.close" title="apsw.Connection.close"><code class="xref py py-meth docutils literal"><span class="pre">Connection.close()</span></code></a> and then continued to use
the <a class="reference internal" href="connection.html#apsw.Connection" title="apsw.Connection"><code class="xref py py-class docutils literal"><span class="pre">Connection</span></code></a> or associated <a class="reference internal" href="cursor.html#apsw.Cursor" title="apsw.Cursor"><code class="xref py py-class docutils literal"><span class="pre">cursors</span></code></a>.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.CursorClosedError">
<em class="property">exception </em><code class="descname">CursorClosedError</code><a class="headerlink" href="#apsw.CursorClosedError" title="Permalink to this definition"></a></dt>
<dd><p>You have called <a class="reference internal" href="cursor.html#apsw.Cursor.close" title="apsw.Cursor.close"><code class="xref py py-meth docutils literal"><span class="pre">Cursor.close()</span></code></a> and then tried to use the cursor.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.BindingsError">
<em class="property">exception </em><code class="descname">BindingsError</code><a class="headerlink" href="#apsw.BindingsError" title="Permalink to this definition"></a></dt>
<dd><p>There are several causes for this exception.  When using tuples, an incorrect number of bindings where supplied:</p>
<div class="highlight-default"><div class="highlight"><pre><span class="n">cursor</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s">&quot;select ?,?,?&quot;</span><span class="p">,</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">))</span>     <span class="c"># too few bindings</span>
<span class="n">cursor</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s">&quot;select ?,?,?&quot;</span><span class="p">,</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">))</span> <span class="c"># too many bindings</span>
</pre></div>
</div>
<p>You are using named bindings, but not all bindings are named.  You should either use entirely the
named style or entirely numeric (unnamed) style:</p>
<div class="highlight-default"><div class="highlight"><pre><span class="n">cursor</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s">&quot;select * from foo where x=:name and y=?&quot;</span><span class="p">)</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>It is not considered an error to have missing keys in a dictionary. For example this is perfectly valid:</p>
<div class="highlight-default"><div class="highlight"><pre><span class="n">cursor</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s">&quot;insert into foo values($a,:b,$c)&quot;</span><span class="p">,</span> <span class="p">{</span><span class="s">&#39;a&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">})</span>
</pre></div>
</div>
<p class="last"><em>b</em> and <em>c</em> are not in the dict.  For missing keys, None/NULL
will be used. This is so you don&#8217;t have to add lots of spurious
values to the supplied dict. If your schema requires every column
have a value, then SQLite will generate an error due to some
values being None/NULL so that case will be caught.</p>
</div>
</dd></dl>

<dl class="exception">
<dt id="apsw.ExecutionCompleteError">
<em class="property">exception </em><code class="descname">ExecutionCompleteError</code><a class="headerlink" href="#apsw.ExecutionCompleteError" title="Permalink to this definition"></a></dt>
<dd><p>A statement is complete but you try to run it more anyway!</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.ExecTraceAbort">
<em class="property">exception </em><code class="descname">ExecTraceAbort</code><a class="headerlink" href="#apsw.ExecTraceAbort" title="Permalink to this definition"></a></dt>
<dd><p>The <a class="reference internal" href="execution.html#executiontracer"><span class="std std-ref">execution tracer</span></a> returned False so
execution was aborted.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.ExtensionLoadingError">
<em class="property">exception </em><code class="descname">ExtensionLoadingError</code><a class="headerlink" href="#apsw.ExtensionLoadingError" title="Permalink to this definition"></a></dt>
<dd><p>An error happened loading an <a class="reference external" href="https://sqlite.org/cvstrac/wiki/wiki?p=LoadableExtensions">extension</a>.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.VFSNotImplementedError">
<em class="property">exception </em><code class="descname">VFSNotImplementedError</code><a class="headerlink" href="#apsw.VFSNotImplementedError" title="Permalink to this definition"></a></dt>
<dd><p>A call cannot be made to an inherited <a class="reference internal" href="vfs.html#vfs"><span class="std std-ref">Virtual File System (VFS)</span></a> method as the VFS
does not implement the method.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.VFSFileClosedError">
<em class="property">exception </em><code class="descname">VFSFileClosedError</code><a class="headerlink" href="#apsw.VFSFileClosedError" title="Permalink to this definition"></a></dt>
<dd><p>The VFS file is closed so the operation cannot be performed.</p>
</dd></dl>

</div>
<div class="section" id="sqlite-exceptions">
<h2>SQLite Exceptions<a class="headerlink" href="#sqlite-exceptions" title="Permalink to this headline"></a></h2>
<p>The following lists which Exception classes correspond to which <a class="reference external" href="https://sqlite.org/c3ref/c_abort.html">SQLite
error codes</a>.</p>
<div class="section" id="general-errors">
<h3>General Errors<a class="headerlink" href="#general-errors" title="Permalink to this headline"></a></h3>
<dl class="exception">
<dt id="apsw.SQLError">
<em class="property">exception </em><code class="descname">SQLError</code><a class="headerlink" href="#apsw.SQLError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_ERROR</span></code>.  This error is documented as a bad SQL query
or missing database, but is also returned for a lot of other
situations.  It is the default error code unless there is a more
specific one.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.MismatchError">
<em class="property">exception </em><code class="descname">MismatchError</code><a class="headerlink" href="#apsw.MismatchError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_MISMATCH</span></code>. Data type mismatch.  For example a rowid
or integer primary key must be an integer.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.NotFoundError">
<em class="property">exception </em><code class="descname">NotFoundError</code><a class="headerlink" href="#apsw.NotFoundError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_NOTFOUND</span></code>. Returned when various internal items were
not found such as requests for non-existent system calls or file
controls.</p>
</dd></dl>

</div>
<div class="section" id="internal-errors">
<h3>Internal Errors<a class="headerlink" href="#internal-errors" title="Permalink to this headline"></a></h3>
<dl class="exception">
<dt id="apsw.InternalError">
<em class="property">exception </em><code class="descname">InternalError</code><a class="headerlink" href="#apsw.InternalError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_INTERNAL</span></code>. (No longer used) Internal logic error in SQLite.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.ProtocolError">
<em class="property">exception </em><code class="descname">ProtocolError</code><a class="headerlink" href="#apsw.ProtocolError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_PROTOCOL</span></code>. (No longer used) Database lock protocol error.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.MisuseError">
<em class="property">exception </em><code class="descname">MisuseError</code><a class="headerlink" href="#apsw.MisuseError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_MISUSE</span></code>.  SQLite library used incorrectly.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.RangeError">
<em class="property">exception </em><code class="descname">RangeError</code><a class="headerlink" href="#apsw.RangeError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_RANGE</span></code>.  (Cannot be generated using APSW).  2nd parameter to <a class="reference external" href="https://sqlite.org/c3ref/bind_blob.html">sqlite3_bind</a> out of range</p>
</dd></dl>

</div>
<div class="section" id="permissions-etc">
<h3>Permissions Etc<a class="headerlink" href="#permissions-etc" title="Permalink to this headline"></a></h3>
<dl class="exception">
<dt id="apsw.PermissionsError">
<em class="property">exception </em><code class="descname">PermissionsError</code><a class="headerlink" href="#apsw.PermissionsError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_PERM</span></code>. Access permission denied by the operating system, or parts of the database are readonly such as a cursor.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.ReadOnlyError">
<em class="property">exception </em><code class="descname">ReadOnlyError</code><a class="headerlink" href="#apsw.ReadOnlyError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_READONLY</span></code>. Attempt to write to a readonly database.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.CantOpenError">
<em class="property">exception </em><code class="descname">CantOpenError</code><a class="headerlink" href="#apsw.CantOpenError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_CANTOPEN</span></code>.  Unable to open the database file.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.AuthError">
<em class="property">exception </em><code class="descname">AuthError</code><a class="headerlink" href="#apsw.AuthError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_AUTH</span></code>.  <a class="reference internal" href="connection.html#apsw.Connection.setauthorizer" title="apsw.Connection.setauthorizer"><code class="xref py py-meth docutils literal"><span class="pre">Authorization</span></code></a> denied.</p>
</dd></dl>

</div>
<div class="section" id="abort-busy-etc">
<h3>Abort/Busy Etc<a class="headerlink" href="#abort-busy-etc" title="Permalink to this headline"></a></h3>
<dl class="exception">
<dt id="apsw.AbortError">
<em class="property">exception </em><code class="descname">AbortError</code><a class="headerlink" href="#apsw.AbortError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_ABORT</span></code>. Callback routine requested an abort.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.BusyError">
<em class="property">exception </em><code class="descname">BusyError</code><a class="headerlink" href="#apsw.BusyError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_BUSY</span></code>.  The database file is locked.  Use
<a class="reference internal" href="connection.html#apsw.Connection.setbusytimeout" title="apsw.Connection.setbusytimeout"><code class="xref py py-meth docutils literal"><span class="pre">Connection.setbusytimeout()</span></code></a> to change how long SQLite waits
for the database to be unlocked or <a class="reference internal" href="connection.html#apsw.Connection.setbusyhandler" title="apsw.Connection.setbusyhandler"><code class="xref py py-meth docutils literal"><span class="pre">Connection.setbusyhandler()</span></code></a>
to use your own handler.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.LockedError">
<em class="property">exception </em><code class="descname">LockedError</code><a class="headerlink" href="#apsw.LockedError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_LOCKED</span></code>.  A table in the database is locked.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.InterruptError">
<em class="property">exception </em><code class="descname">InterruptError</code><a class="headerlink" href="#apsw.InterruptError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_INTERRUPT</span></code>.  Operation terminated by
<a class="reference external" href="https://sqlite.org/c3ref/interrupt.html">sqlite3_interrupt</a> -
use <a class="reference internal" href="connection.html#apsw.Connection.interrupt" title="apsw.Connection.interrupt"><code class="xref py py-meth docutils literal"><span class="pre">Connection.interrupt()</span></code></a>.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.SchemaChangeError">
<em class="property">exception </em><code class="descname">SchemaChangeError</code><a class="headerlink" href="#apsw.SchemaChangeError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_SCHEMA</span></code>.  The database schema changed.  A
<a class="reference internal" href="cursor.html#apsw.Cursor.execute" title="apsw.Cursor.execute"><code class="xref py py-meth docutils literal"><span class="pre">prepared</span> <span class="pre">statement</span></code></a> becomes invalid
if the database schema was changed.  Behind the scenes SQLite
reprepares the statement.  Another or the same <a class="reference internal" href="connection.html#apsw.Connection" title="apsw.Connection"><code class="xref py py-class docutils literal"><span class="pre">Connection</span></code></a>
may change the schema again before the statement runs.  SQLite will
attempt up to 5 times before giving up and returning this error.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.ConstraintError">
<em class="property">exception </em><code class="descname">ConstraintError</code><a class="headerlink" href="#apsw.ConstraintError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_CONSTRAINT</span></code>. Abort due to <a class="reference external" href="https://sqlite.org/lang_createtable.html">constraint</a> violation.  This
would happen if the schema required a column to be within a specific
range.  If you have multiple constraints, you <a class="reference external" href="https://sqlite.org/src/tktview/23b212820161c6599cbf414aa99bf8a5bfa5e7a3">can&#8217;t tell</a>
which one was the cause.</p>
</dd></dl>

</div>
<div class="section" id="memory-disk">
<h3>Memory/Disk<a class="headerlink" href="#memory-disk" title="Permalink to this headline"></a></h3>
<dl class="exception">
<dt id="apsw.NoMemError">
<em class="property">exception </em><code class="descname">NoMemError</code><a class="headerlink" href="#apsw.NoMemError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_NOMEM</span></code>.  A memory allocation failed.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.IOError">
<em class="property">exception </em><code class="descname">IOError</code><a class="headerlink" href="#apsw.IOError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_IOERR</span></code>.  Some kind of disk I/O error occurred.  The
<a class="reference internal" href="#exceptions"><span class="std std-ref">extended error code</span></a> will give more detail.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.CorruptError">
<em class="property">exception </em><code class="descname">CorruptError</code><a class="headerlink" href="#apsw.CorruptError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_CORRUPT</span></code>.  The database disk image appears to be a
SQLite database but the values inside are inconsistent.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.FullError">
<em class="property">exception </em><code class="descname">FullError</code><a class="headerlink" href="#apsw.FullError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_FULL</span></code>.  The disk appears to be full.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.TooBigError">
<em class="property">exception </em><code class="descname">TooBigError</code><a class="headerlink" href="#apsw.TooBigError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_TOOBIG</span></code>.  String or BLOB exceeds size limit.  You can
change the limits using <a class="reference internal" href="connection.html#apsw.Connection.limit" title="apsw.Connection.limit"><code class="xref py py-meth docutils literal"><span class="pre">Connection.limit()</span></code></a>.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.NoLFSError">
<em class="property">exception </em><code class="descname">NoLFSError</code><a class="headerlink" href="#apsw.NoLFSError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_NOLFS</span></code>.  SQLite has attempted to use a feature not
supported by the operating system such as <a class="reference external" href="http://en.wikipedia.org/wiki/Large_file_support">large file support</a>.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.EmptyError">
<em class="property">exception </em><code class="descname">EmptyError</code><a class="headerlink" href="#apsw.EmptyError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_EMPTY</span></code>. Database is completely empty.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.FormatError">
<em class="property">exception </em><code class="descname">FormatError</code><a class="headerlink" href="#apsw.FormatError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_FORMAT</span></code>. (No longer used) <a class="reference external" href="https://sqlite.org/lang_attach.html">Auxiliary database</a> format error.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.NotADBError">
<em class="property">exception </em><code class="descname">NotADBError</code><a class="headerlink" href="#apsw.NotADBError" title="Permalink to this definition"></a></dt>
<dd><p><code class="xref py py-const docutils literal"><span class="pre">SQLITE_NOTADB</span></code>.  File opened that is not a database file.
SQLite has a header on database files to verify they are indeed
SQLite databases.</p>
</dd></dl>

</div>
</div>
<div class="section" id="augmented-stack-traces">
<span id="augmentedstacktraces"></span><h2>Augmented stack traces<a class="headerlink" href="#augmented-stack-traces" title="Permalink to this headline"></a></h2>
<p>When an exception occurs, Python does not include frames from
non-Python code (ie the C code called from Python).  This can make it
more difficult to work out what was going on when an exception
occurred for example when there are callbacks to collations, functions
or virtual tables, triggers firing etc.</p>
<p>This is an example showing the difference between the tracebacks you
would have got with earlier versions of apsw and the augmented
traceback:</p>
<div class="highlight-default"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">apsw</span>

<span class="k">def</span> <span class="nf">myfunc</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
  <span class="mi">1</span><span class="o">/</span><span class="mi">0</span>

<span class="n">con</span><span class="o">=</span><span class="n">apsw</span><span class="o">.</span><span class="n">Connection</span><span class="p">(</span><span class="s">&quot;:memory:&quot;</span><span class="p">)</span>
<span class="n">con</span><span class="o">.</span><span class="n">createscalarfunction</span><span class="p">(</span><span class="s">&quot;foo&quot;</span><span class="p">,</span> <span class="n">myfunc</span><span class="p">)</span>
<span class="n">con</span><span class="o">.</span><span class="n">createscalarfunction</span><span class="p">(</span><span class="s">&quot;fam&quot;</span><span class="p">,</span> <span class="n">myfunc</span><span class="p">)</span>
<span class="n">cursor</span><span class="o">=</span><span class="n">con</span><span class="o">.</span><span class="n">cursor</span><span class="p">()</span>
<span class="n">cursor</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s">&quot;create table bar(x,y,z);insert into bar values(1,2,3)&quot;</span><span class="p">)</span>
<span class="n">cursor</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s">&quot;select foo(1) from bar&quot;</span><span class="p">)</span>
</pre></div>
</div>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Original Traceback</th>
<th class="head">Augmented Traceback</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><div class="first last highlight-default"><div class="highlight"><pre><span class="n">Traceback</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">last</span><span class="p">):</span>
  <span class="n">File</span> <span class="s">&quot;t.py&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">11</span><span class="p">,</span> <span class="ow">in</span> <span class="o">&lt;</span><span class="n">module</span><span class="o">&gt;</span>
    <span class="n">cursor</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s">&quot;select foo(1) from bar&quot;</span><span class="p">)</span>
  <span class="n">File</span> <span class="s">&quot;t.py&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">4</span><span class="p">,</span> <span class="ow">in</span> <span class="n">myfunc</span>
    <span class="mi">1</span><span class="o">/</span><span class="mi">0</span>
<span class="ne">ZeroDivisionError</span><span class="p">:</span> <span class="n">integer</span> <span class="n">division</span> <span class="ow">or</span> <span class="n">modulo</span> <span class="n">by</span> <span class="n">zero</span>
</pre></div>
</div>
</td>
<td><div class="first last highlight-default"><div class="highlight"><pre><span class="n">Traceback</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">last</span><span class="p">):</span>
  <span class="n">File</span> <span class="s">&quot;t.py&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">11</span><span class="p">,</span> <span class="ow">in</span> <span class="o">&lt;</span><span class="n">module</span><span class="o">&gt;</span>
    <span class="n">cursor</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s">&quot;select foo(1) from bar&quot;</span><span class="p">)</span>
  <span class="n">File</span> <span class="s">&quot;apsw.c&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">3412</span><span class="p">,</span> <span class="ow">in</span> <span class="n">resetcursor</span>
  <span class="n">File</span> <span class="s">&quot;apsw.c&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">1597</span><span class="p">,</span> <span class="ow">in</span> <span class="n">user</span><span class="o">-</span><span class="n">defined</span><span class="o">-</span><span class="n">scalar</span><span class="o">-</span><span class="n">foo</span>
  <span class="n">File</span> <span class="s">&quot;t.py&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">4</span><span class="p">,</span> <span class="ow">in</span> <span class="n">myfunc</span>
    <span class="mi">1</span><span class="o">/</span><span class="mi">0</span>
<span class="ne">ZeroDivisionError</span><span class="p">:</span> <span class="n">integer</span> <span class="n">division</span> <span class="ow">or</span> <span class="n">modulo</span> <span class="n">by</span> <span class="n">zero</span>
</pre></div>
</div>
</td>
</tr>
</tbody>
</table>
<p>In the original traceback you can&#8217;t even see that code in apsw was
involved. The augmented traceback shows that there were indeed two
function calls within apsw and gives you line numbers should you need
to examine the code. Also note how you are told that the call was in
<cite>user-defined-scalar-foo</cite> (ie you can tell which function was called.)</p>
<p><em>But wait, there is more!!!</em> In order to further aid troubleshooting,
the augmented stack traces make additional information available. Each
frame in the traceback has local variables defined with more
information. You can print out the variables using <a class="reference external" href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52215">ASPN recipe 52215</a></p>
<blockquote>
<div><p>In the recipe, the initial code in <code class="xref py py-func docutils literal"><span class="pre">print_exc_plus()</span></code> is far
more complicated than need be, and also won&#8217;t work correctly with
all tracebacks (it depends on <code class="xref py py-attr docutils literal"><span class="pre">f_prev</span></code> being set which isn&#8217;t always
the case). Change the function to start like this:</p>
<div class="highlight-default"><div class="highlight"><pre><span class="n">tb</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">exc_info</span><span class="p">()[</span><span class="mi">2</span><span class="p">]</span>
<span class="n">stack</span> <span class="o">=</span> <span class="p">[]</span>

<span class="k">while</span> <span class="n">tb</span><span class="p">:</span>
    <span class="n">stack</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="p">)</span>
    <span class="n">tb</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_next</span>

<span class="n">traceback</span><span class="o">.</span><span class="n">print_exc</span><span class="p">()</span>
<span class="nb">print</span> <span class="s">&quot;Locals by frame, innermost last&quot;</span>
</pre></div>
</div>
</div></blockquote>
<p>Here is a far more complex example from some <a class="reference internal" href="vtable.html#virtualtables"><span class="std std-ref">virtual tables</span></a> code I was writing. The BestIndex method in my code
had returned an incorrect value. The augmented traceback includes
local variables using recipe 52215. I can see what was passed in to my
method, what I returned and which item was erroneous. The original
traceback is almost completely useless.</p>
<p>Original traceback:</p>
<div class="highlight-default"><div class="highlight"><pre><span class="n">Traceback</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">last</span><span class="p">):</span>
  <span class="n">File</span> <span class="s">&quot;tests.py&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">1387</span><span class="p">,</span> <span class="ow">in</span> <span class="n">testVtables</span>
    <span class="n">cursor</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">allconstraints</span><span class="p">)</span>
<span class="ne">TypeError</span><span class="p">:</span> <span class="n">Bad</span> <span class="n">constraint</span> <span class="p">(</span><span class="c">#2) - it should be one of None, an integer or a tuple of an integer and a boolean</span>
</pre></div>
</div>
<p>Augmented traceback with local variables:</p>
<div class="highlight-default"><div class="highlight"><pre><span class="n">Traceback</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">last</span><span class="p">):</span>
  <span class="n">File</span> <span class="s">&quot;tests.py&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">1387</span><span class="p">,</span> <span class="ow">in</span> <span class="n">testVtables</span>
    <span class="n">cursor</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">allconstraints</span><span class="p">)</span>
                <span class="n">VTable</span> <span class="o">=</span>  <span class="n">__main__</span><span class="o">.</span><span class="n">VTable</span>
                   <span class="n">cur</span> <span class="o">=</span>  <span class="o">&lt;</span><span class="n">apsw</span><span class="o">.</span><span class="n">Cursor</span> <span class="nb">object</span> <span class="n">at</span> <span class="mh">0x988f30</span><span class="o">&gt;</span>
                     <span class="n">i</span> <span class="o">=</span>  <span class="mi">10</span>
                  <span class="bp">self</span> <span class="o">=</span>  <span class="n">testVtables</span> <span class="p">(</span><span class="n">__main__</span><span class="o">.</span><span class="n">APSW</span><span class="p">)</span>
        <span class="n">allconstraints</span> <span class="o">=</span>  <span class="n">select</span> <span class="n">rowid</span><span class="p">,</span><span class="o">*</span> <span class="kn">from</span> <span class="nn">foo</span> <span class="n">where</span> <span class="n">rowid</span><span class="o">&gt;-</span><span class="mi">1000</span> <span class="o">....</span>

  <span class="n">File</span> <span class="s">&quot;apsw.c&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">4050</span><span class="p">,</span> <span class="ow">in</span> <span class="n">Cursor_execute</span><span class="o">.</span><span class="n">sqlite3_prepare</span>
            <span class="n">Connection</span> <span class="o">=</span>  <span class="o">&lt;</span><span class="n">apsw</span><span class="o">.</span><span class="n">Connection</span> <span class="nb">object</span> <span class="n">at</span> <span class="mh">0x978800</span><span class="o">&gt;</span>
             <span class="n">statement</span> <span class="o">=</span>  <span class="n">select</span> <span class="n">rowid</span><span class="p">,</span><span class="o">*</span> <span class="kn">from</span> <span class="nn">foo</span> <span class="n">where</span> <span class="n">rowid</span><span class="o">&gt;-</span><span class="mi">1000</span> <span class="o">....</span>

  <span class="n">File</span> <span class="s">&quot;apsw.c&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">2681</span><span class="p">,</span> <span class="ow">in</span> <span class="n">VirtualTable</span><span class="o">.</span><span class="n">xBestIndex</span>
                  <span class="bp">self</span> <span class="o">=</span>  <span class="o">&lt;</span><span class="n">__main__</span><span class="o">.</span><span class="n">VTable</span> <span class="n">instance</span> <span class="n">at</span> <span class="mh">0x98d8c0</span><span class="o">&gt;</span>
                  <span class="n">args</span> <span class="o">=</span>  <span class="p">(((</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">32</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">64</span><span class="p">)),</span> <span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="k">False</span><span class="p">),))</span>
                <span class="n">result</span> <span class="o">=</span>  <span class="p">([</span><span class="mi">4</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,),</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="k">False</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">]],</span> <span class="mi">997</span><span class="p">,</span> <span class="s">u&#39;</span><span class="se">\xea</span><span class="s">&#39;</span><span class="p">,</span> <span class="k">False</span><span class="p">)</span>

  <span class="n">File</span> <span class="s">&quot;apsw.c&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">2559</span><span class="p">,</span> <span class="ow">in</span> <span class="n">VirtualTable</span><span class="o">.</span><span class="n">xBestIndex</span><span class="o">.</span><span class="n">result_constraint</span>
               <span class="n">indices</span> <span class="o">=</span>  <span class="p">[</span><span class="mi">4</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,),</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="k">False</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
                  <span class="bp">self</span> <span class="o">=</span>  <span class="o">&lt;</span><span class="n">__main__</span><span class="o">.</span><span class="n">VTable</span> <span class="n">instance</span> <span class="n">at</span> <span class="mh">0x98d8c0</span><span class="o">&gt;</span>
                <span class="n">result</span> <span class="o">=</span>  <span class="p">([</span><span class="mi">4</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,),</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="k">False</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">]],</span> <span class="mi">997</span><span class="p">,</span> <span class="s">u&#39;</span><span class="se">\xea</span><span class="s">&#39;</span><span class="p">,</span> <span class="k">False</span><span class="p">)</span>
            <span class="n">constraint</span> <span class="o">=</span>  <span class="p">(</span><span class="mi">3</span><span class="p">,)</span>

<span class="ne">TypeError</span><span class="p">:</span> <span class="n">Bad</span> <span class="n">constraint</span> <span class="p">(</span><span class="c">#2) - it should be one of None, an integer or a tuple of an integer and a boolean</span>
</pre></div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Exceptions</a><ul>
<li><a class="reference internal" href="#apsw-specific-exceptions">APSW specific exceptions</a></li>
<li><a class="reference internal" href="#sqlite-exceptions">SQLite Exceptions</a><ul>
<li><a class="reference internal" href="#general-errors">General Errors</a></li>
<li><a class="reference internal" href="#internal-errors">Internal Errors</a></li>
<li><a class="reference internal" href="#permissions-etc">Permissions Etc</a></li>
<li><a class="reference internal" href="#abort-busy-etc">Abort/Busy Etc</a></li>
<li><a class="reference internal" href="#memory-disk">Memory/Disk</a></li>
</ul>
</li>
<li><a class="reference internal" href="#augmented-stack-traces">Augmented stack traces</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="shell.html"
                        title="previous chapter">Shell</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="types.html"
                        title="next chapter">Types</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/exceptions.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <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="types.html" title="Types"
             >next</a> |</li>
        <li class="right" >
          <a href="shell.html" title="Shell"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">APSW 3.16.2-r1 documentation</a> &#187;</li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; <a href="copyright.html">Copyright</a> 2004-2016, Roger Binns &lt;rogerb@rogerbinns.com&gt;.
      Last updated on Jan 14, 2017.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.8.
    </div>

  </body>
</html>