This file is indexed.

/usr/share/doc/python-apsw/html/exceptions.html is in python-apsw-doc 3.7.6.3-r1-1build1.

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
<!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 &mdash; APSW 3.7.6.3-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.7.6.3-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.7.6.3-r1 documentation" href="index.html" />
    <link rel="next" title="Types" href="types.html" />
    <link rel="prev" title="Shell" href="shell.html" /> 
  </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="types.html" title="Types"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="shell.html" title="Shell"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">APSW 3.7.6.3-r1 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <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"><tt class="xref py py-exc docutils literal"><span class="pre">apsw.Error</span></tt></a> is the base for APSW exceptions.</p>
<dl class="exception">
<dt id="apsw.Error">
<em class="property">exception </em><tt class="descname">Error</tt><a class="headerlink" href="#apsw.Error" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="apsw.Error.result">
<tt class="descclassname">Error.</tt><tt class="descname">result</tt><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="http://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">
<tt class="descclassname">Error.</tt><tt class="descname">extendedresult</tt><a class="headerlink" href="#apsw.Error.extendedresult" title="Permalink to this definition"></a></dt>
<dd><p>APSW runs with <a class="reference external" href="http://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"><tt class="xref py py-attr docutils literal"><span class="pre">result</span></tt></a> would have the value
<tt class="xref py py-const docutils literal"><span class="pre">SQLITE_IOERR</span></tt> while <a class="reference internal" href="#apsw.Error.extendedresult" title="apsw.Error.extendedresult"><tt class="xref py py-attr docutils literal"><span class="pre">extendedresult</span></tt></a> would have
the value <tt class="xref py py-const docutils literal"><span class="pre">SQLITE_IOERR_SHORT_READ</span></tt>.</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><tt class="descname">ThreadingViolationError</tt><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"><tt class="xref py py-meth docutils literal"><span class="pre">Cursor.executemany()</span></tt></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><tt class="descname">ForkingViolationError</tt><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"><tt class="xref py py-meth docutils literal"><span class="pre">apsw.fork_checker()</span></tt></a>.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.IncompleteExecutionError">
<em class="property">exception </em><tt class="descname">IncompleteExecutionError</tt><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"><em>execution model</em></a>
for more details.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.ConnectionNotClosedError">
<em class="property">exception </em><tt class="descname">ConnectionNotClosedError</tt><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><tt class="descname">ConnectionClosedError</tt><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"><tt class="xref py py-meth docutils literal"><span class="pre">Connection.close()</span></tt></a> and then continued to use
the <a class="reference internal" href="connection.html#apsw.Connection" title="apsw.Connection"><tt class="xref py py-class docutils literal"><span class="pre">Connection</span></tt></a> or associated <a class="reference internal" href="cursor.html#apsw.Cursor" title="apsw.Cursor"><tt class="xref py py-class docutils literal"><span class="pre">cursors</span></tt></a>.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.CursorClosedError">
<em class="property">exception </em><tt class="descname">CursorClosedError</tt><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"><tt class="xref py py-meth docutils literal"><span class="pre">Cursor.close()</span></tt></a> and then tried to use the cursor.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.BindingsError">
<em class="property">exception </em><tt class="descname">BindingsError</tt><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-python"><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-python"><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-python"><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><tt class="descname">ExecutionCompleteError</tt><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><tt class="descname">ExecTraceAbort</tt><a class="headerlink" href="#apsw.ExecTraceAbort" title="Permalink to this definition"></a></dt>
<dd><p>The <a class="reference internal" href="execution.html#executiontracer"><em>execution tracer</em></a> returned False so
execution was aborted.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.ExtensionLoadingError">
<em class="property">exception </em><tt class="descname">ExtensionLoadingError</tt><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="http://www.sqlite.org/cvstrac/wiki/wiki?p=LoadableExtensions">extension</a>.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.VFSNotImplementedError">
<em class="property">exception </em><tt class="descname">VFSNotImplementedError</tt><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"><em>Virtual File System (VFS)</em></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><tt class="descname">VFSFileClosedError</tt><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="http://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><tt class="descname">SQLError</tt><a class="headerlink" href="#apsw.SQLError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_ERROR</span></tt>.  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.  (See <a class="reference external" href="http://www.sqlite.org/cvstrac/tktview?tn=3456">SQLite ticket #3456</a>.)</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.MismatchError">
<em class="property">exception </em><tt class="descname">MismatchError</tt><a class="headerlink" href="#apsw.MismatchError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_MISMATCH</span></tt>. 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><tt class="descname">NotFoundError</tt><a class="headerlink" href="#apsw.NotFoundError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_NOTFOUND</span></tt>. 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><tt class="descname">InternalError</tt><a class="headerlink" href="#apsw.InternalError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_INTERNAL</span></tt>. (No longer used) Internal logic error in SQLite.</p>
</dd></dl>

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

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

<dl class="exception">
<dt id="apsw.RangeError">
<em class="property">exception </em><tt class="descname">RangeError</tt><a class="headerlink" href="#apsw.RangeError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_RANGE</span></tt>.  (Cannot be generated using APSW).  2nd parameter to <a class="reference external" href="http://www.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><tt class="descname">PermissionsError</tt><a class="headerlink" href="#apsw.PermissionsError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_PERM</span></tt>. 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><tt class="descname">ReadOnlyError</tt><a class="headerlink" href="#apsw.ReadOnlyError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_READONLY</span></tt>. Attempt to write to a readonly database.</p>
</dd></dl>

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

<dl class="exception">
<dt id="apsw.AuthError">
<em class="property">exception </em><tt class="descname">AuthError</tt><a class="headerlink" href="#apsw.AuthError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_AUTH</span></tt>.  <a class="reference internal" href="connection.html#apsw.Connection.setauthorizer" title="apsw.Connection.setauthorizer"><tt class="xref py py-meth docutils literal"><span class="pre">Authorization</span></tt></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><tt class="descname">AbortError</tt><a class="headerlink" href="#apsw.AbortError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_ABORT</span></tt>. Callback routine requested an abort.</p>
</dd></dl>

<dl class="exception">
<dt id="apsw.BusyError">
<em class="property">exception </em><tt class="descname">BusyError</tt><a class="headerlink" href="#apsw.BusyError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_BUSY</span></tt>.  The database file is locked.  Use
<a class="reference internal" href="connection.html#apsw.Connection.setbusytimeout" title="apsw.Connection.setbusytimeout"><tt class="xref py py-meth docutils literal"><span class="pre">Connection.setbusytimeout()</span></tt></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"><tt class="xref py py-meth docutils literal"><span class="pre">Connection.setbusyhandler()</span></tt></a>
to use your own handler.</p>
</dd></dl>

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

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

<dl class="exception">
<dt id="apsw.SchemaChangeError">
<em class="property">exception </em><tt class="descname">SchemaChangeError</tt><a class="headerlink" href="#apsw.SchemaChangeError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_SCHEMA</span></tt>.  The database schema changed.  A
<a class="reference internal" href="cursor.html#apsw.Cursor.execute" title="apsw.Cursor.execute"><tt class="xref py py-meth docutils literal"><span class="pre">prepared</span> <span class="pre">statement</span></tt></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"><tt class="xref py py-class docutils literal"><span class="pre">Connection</span></tt></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><tt class="descname">ConstraintError</tt><a class="headerlink" href="#apsw.ConstraintError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_CONSTRAINT</span></tt>. Abort due to <a class="reference external" href="http://www.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="http://www.sqlite.org/cvstrac/tktview?tn=1648">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><tt class="descname">NoMemError</tt><a class="headerlink" href="#apsw.NoMemError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_NOMEM</span></tt>.  A memory allocation failed.</p>
</dd></dl>

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

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

<dl class="exception">
<dt id="apsw.TooBigError">
<em class="property">exception </em><tt class="descname">TooBigError</tt><a class="headerlink" href="#apsw.TooBigError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_TOOBIG</span></tt>.  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"><tt class="xref py py-meth docutils literal"><span class="pre">Connection.limit()</span></tt></a>.</p>
</dd></dl>

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

<dl class="exception">
<dt id="apsw.FormatError">
<em class="property">exception </em><tt class="descname">FormatError</tt><a class="headerlink" href="#apsw.FormatError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_FORMAT</span></tt>. (No longer used) <a class="reference external" href="http://www.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><tt class="descname">NotADBError</tt><a class="headerlink" href="#apsw.NotADBError" title="Permalink to this definition"></a></dt>
<dd><p><tt class="xref py py-const docutils literal"><span class="pre">SQLITE_NOTADB</span></tt>.  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-python"><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-python"><pre>Traceback (most recent call last):
  File "t.py", line 11, in &lt;module&gt;
    cursor.execute("select foo(1) from bar")
  File "t.py", line 4, in myfunc
    1/0
ZeroDivisionError: integer division or modulo by zero</pre>
</div>
</td>
<td><div class="first last highlight-python"><pre>Traceback (most recent call last):
  File "t.py", line 11, in &lt;module&gt;
    cursor.execute("select foo(1) from bar")
  File "apsw.c", line 3412, in resetcursor
  File "apsw.c", line 1597, in user-defined-scalar-foo
  File "t.py", line 4, in myfunc
    1/0
ZeroDivisionError: integer division or modulo by zero</pre>
</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 <tt class="xref py py-func docutils literal"><span class="pre">print_exc_plus()</span></tt> is far
more complicated than need be, and also won&#8217;t work correctly with
all tracebacks (it depends on <tt class="xref py py-attr docutils literal"><span class="pre">f_prev</span></tt> being set which isn&#8217;t always
the case). Change the function to start like this:</p>
<div class="highlight-python"><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="k">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"><em>virtual tables</em></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-python"><pre>Traceback (most recent call last):
  File "tests.py", line 1387, in testVtables
    cursor.execute(allconstraints)
TypeError: Bad constraint (#2) - it should be one of None, an integer or a tuple of an integer and a boolean</pre>
</div>
<p>Augmented traceback with local variables:</p>
<div class="highlight-python"><pre>Traceback (most recent call last):
  File "tests.py", line 1387, in testVtables
    cursor.execute(allconstraints)
                VTable =  __main__.VTable
                   cur =  &lt;apsw.Cursor object at 0x988f30&gt;
                     i =  10
                  self =  testVtables (__main__.APSW)
        allconstraints =  select rowid,* from foo where rowid&gt;-1000 ....

  File "apsw.c", line 4050, in Cursor_execute.sqlite3_prepare
            Connection =  &lt;apsw.Connection object at 0x978800&gt;
             statement =  select rowid,* from foo where rowid&gt;-1000 ....

  File "apsw.c", line 2681, in VirtualTable.xBestIndex
                  self =  &lt;__main__.VTable instance at 0x98d8c0&gt;
                  args =  (((-1, 4), (0, 32), (1, 8), (2, 4), (3, 64)), ((2, False),))
                result =  ([4, (3,), [2, False], [1], [0]], 997, u'\xea', False)

  File "apsw.c", line 2559, in VirtualTable.xBestIndex.result_constraint
               indices =  [4, (3,), [2, False], [1], [0]]
                  self =  &lt;__main__.VTable instance at 0x98d8c0&gt;
                result =  ([4, (3,), [2, False], [1], [0]], 997, u'\xea', False)
            constraint =  (3,)

TypeError: Bad constraint (#2) - it should be one of None, an integer or a tuple of an integer and a boolean</pre>
</div>
</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="#">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>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/exceptions.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" size="18" />
      <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="types.html" title="Types"
             >next</a> |</li>
        <li class="right" >
          <a href="shell.html" title="Shell"
             >previous</a> |</li>
        <li><a href="index.html">APSW 3.7.6.3-r1 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; <a href="copyright.html">Copyright</a> 2004-2010, Roger Binns &lt;rogerb@rogerbinns.com&gt;.
      Last updated on May 20, 2011.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1pre/4b8d012cf82e.
    </div>
  </body>
</html>