/usr/share/doc/python3-postgresql/html/_modules/postgresql/exceptions.html is in python3-postgresql 1.1.0-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 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 | <!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>postgresql.exceptions — py-postgresql 1.1.0 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: '1.1.0',
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="top" title="py-postgresql 1.1.0 documentation" href="../../index.html" />
<link rel="up" title="postgresql" href="../postgresql.html" />
<link rel="stylesheet" href="_static/unsuck.css" type="text/css" />
</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><a href="../../index.html">py-postgresql 1.1.0 documentation</a> »</li>
<li><a href="../index.html" >Module code</a> »</li>
<li><a href="../postgresql.html" accesskey="U">postgresql</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<h1>Source code for postgresql.exceptions</h1><div class="highlight"><pre>
<span class="c">##</span>
<span class="c"># .exceptions - Exception hierarchy for PostgreSQL database ERRORs.</span>
<span class="c">##</span>
<span class="sd">"""</span>
<span class="sd">PostgreSQL exceptions and warnings with associated state codes.</span>
<span class="sd">The primary entry points of this module is the `ErrorLookup` function and the</span>
<span class="sd">`WarningLookup` function. Given an SQL state code, they give back the most</span>
<span class="sd">appropriate Error or Warning subclass.</span>
<span class="sd">For more information on error codes see:</span>
<span class="sd"> http://www.postgresql.org/docs/current/static/errcodes-appendix.html</span>
<span class="sd">This module is executable via -m: python -m postgresql.exceptions.</span>
<span class="sd">It provides a convenient way to look up the exception object mapped to by the</span>
<span class="sd">given error code::</span>
<span class="sd"> $ python -m postgresql.exceptions XX000</span>
<span class="sd"> postgresql.exceptions.InternalError [XX000]</span>
<span class="sd">If the exact error code is not found, it will try to find the error class's</span>
<span class="sd">exception(The first two characters of the error code make up the class</span>
<span class="sd">identity)::</span>
<span class="sd"> $ python -m postgresql.exceptions XX400</span>
<span class="sd"> postgresql.exceptions.InternalError [XX000]</span>
<span class="sd">If that fails, it will return `postgresql.exceptions.Error`</span>
<span class="sd">"""</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">partial</span>
<span class="kn">from</span> <span class="nn">operator</span> <span class="kn">import</span> <span class="n">attrgetter</span>
<span class="kn">from</span> <span class="nn">.message</span> <span class="kn">import</span> <span class="n">Message</span>
<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">sys</span> <span class="k">as</span> <span class="n">pg_sys</span>
<span class="n">PythonException</span> <span class="o">=</span> <span class="ne">Exception</span>
<div class="viewcode-block" id="Exception"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.Exception">[docs]</a><span class="k">class</span> <span class="nc">Exception</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
<span class="s">'Base PostgreSQL exception class'</span>
<span class="k">pass</span>
</div>
<div class="viewcode-block" id="LoadError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.LoadError">[docs]</a><span class="k">class</span> <span class="nc">LoadError</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
<span class="s">'Failed to load a library'</span>
</div>
<div class="viewcode-block" id="Disconnection"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.Disconnection">[docs]</a><span class="k">class</span> <span class="nc">Disconnection</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
<span class="s">'Exception identifying errors that result in disconnection'</span>
</div>
<span class="k">class</span> <span class="nc">Warning</span><span class="p">(</span><span class="n">Message</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'01000'</span>
<span class="n">_e_label</span> <span class="o">=</span> <span class="nb">property</span><span class="p">(</span><span class="n">attrgetter</span><span class="p">(</span><span class="s">'__class__.__name__'</span><span class="p">))</span>
<span class="k">class</span> <span class="nc">DriverWarning</span><span class="p">(</span><span class="ne">Warning</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'01-00'</span>
<span class="n">source</span> <span class="o">=</span> <span class="s">'CLIENT'</span>
<div class="viewcode-block" id="IgnoredClientParameterWarning"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.IgnoredClientParameterWarning">[docs]</a><span class="k">class</span> <span class="nc">IgnoredClientParameterWarning</span><span class="p">(</span><span class="n">DriverWarning</span><span class="p">):</span>
<span class="s">'Warn the user of a valid, but ignored parameter.'</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'01-CP'</span></div>
<div class="viewcode-block" id="TypeConversionWarning"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.TypeConversionWarning">[docs]</a><span class="k">class</span> <span class="nc">TypeConversionWarning</span><span class="p">(</span><span class="n">DriverWarning</span><span class="p">):</span>
<span class="s">'Report a potential issue with a conversion.'</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'01-TP'</span>
</div>
<span class="k">class</span> <span class="nc">DeprecationWarning</span><span class="p">(</span><span class="ne">Warning</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'01P01'</span>
<span class="k">class</span> <span class="nc">DynamicResultSetsReturnedWarning</span><span class="p">(</span><span class="ne">Warning</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'0100C'</span>
<span class="k">class</span> <span class="nc">ImplicitZeroBitPaddingWarning</span><span class="p">(</span><span class="ne">Warning</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'01008'</span>
<span class="k">class</span> <span class="nc">NullValueEliminatedInSetFunctionWarning</span><span class="p">(</span><span class="ne">Warning</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'01003'</span>
<span class="k">class</span> <span class="nc">PrivilegeNotGrantedWarning</span><span class="p">(</span><span class="ne">Warning</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'01007'</span>
<span class="k">class</span> <span class="nc">PrivilegeNotRevokedWarning</span><span class="p">(</span><span class="ne">Warning</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'01006'</span>
<span class="k">class</span> <span class="nc">StringDataRightTruncationWarning</span><span class="p">(</span><span class="ne">Warning</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'01004'</span>
<span class="k">class</span> <span class="nc">NoDataWarning</span><span class="p">(</span><span class="ne">Warning</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'02000'</span>
<span class="k">class</span> <span class="nc">NoMoreSetsReturned</span><span class="p">(</span><span class="n">NoDataWarning</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'02001'</span>
<div class="viewcode-block" id="Error"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.Error">[docs]</a><span class="k">class</span> <span class="nc">Error</span><span class="p">(</span><span class="n">Message</span><span class="p">,</span> <span class="ne">Exception</span><span class="p">):</span>
<span class="s">'A PostgreSQL Error'</span>
<span class="n">_e_label</span> <span class="o">=</span> <span class="s">'ERROR'</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">''</span>
<span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="s">'Call .sys.errformat(self)'</span>
<span class="k">return</span> <span class="n">pg_sys</span><span class="o">.</span><span class="n">errformat</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">fatal</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">f</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">details</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'severity'</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">None</span> <span class="k">if</span> <span class="n">f</span> <span class="ow">is</span> <span class="bp">None</span> <span class="k">else</span> <span class="n">f</span> <span class="ow">in</span> <span class="p">(</span><span class="s">'PANIC'</span><span class="p">,</span> <span class="s">'FATAL'</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="DriverError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.DriverError">[docs]</a><span class="k">class</span> <span class="nc">DriverError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"Errors originating in the driver's implementation."</span>
<span class="n">source</span> <span class="o">=</span> <span class="s">'CLIENT'</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'--000'</span></div>
<div class="viewcode-block" id="AuthenticationMethodError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.AuthenticationMethodError">[docs]</a><span class="k">class</span> <span class="nc">AuthenticationMethodError</span><span class="p">(</span><span class="n">DriverError</span><span class="p">,</span> <span class="n">Disconnection</span><span class="p">):</span>
<span class="sd">"""</span>
<span class="sd"> Server requested an authentication method that is not supported by the</span>
<span class="sd"> driver.</span>
<span class="sd"> """</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'--AUT'</span></div>
<div class="viewcode-block" id="InsecurityError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.InsecurityError">[docs]</a><span class="k">class</span> <span class="nc">InsecurityError</span><span class="p">(</span><span class="n">DriverError</span><span class="p">,</span> <span class="n">Disconnection</span><span class="p">):</span>
<span class="sd">"""</span>
<span class="sd"> Error signifying a secure channel to a server cannot be established.</span>
<span class="sd"> """</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'--SEC'</span></div>
<div class="viewcode-block" id="ConnectTimeoutError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.ConnectTimeoutError">[docs]</a><span class="k">class</span> <span class="nc">ConnectTimeoutError</span><span class="p">(</span><span class="n">DriverError</span><span class="p">,</span> <span class="n">Disconnection</span><span class="p">):</span>
<span class="s">'Client was unable to esablish a connection in the given time'</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'--TOE'</span>
</div>
<div class="viewcode-block" id="TypeIOError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.TypeIOError">[docs]</a><span class="k">class</span> <span class="nc">TypeIOError</span><span class="p">(</span><span class="n">DriverError</span><span class="p">):</span>
<span class="sd">"""</span>
<span class="sd"> Driver failed to pack or unpack a tuple.</span>
<span class="sd"> """</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'--TIO'</span></div>
<span class="k">class</span> <span class="nc">ParameterError</span><span class="p">(</span><span class="n">TypeIOError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'--PIO'</span>
<span class="k">class</span> <span class="nc">ColumnError</span><span class="p">(</span><span class="n">TypeIOError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'--CIO'</span>
<span class="k">class</span> <span class="nc">CompositeError</span><span class="p">(</span><span class="n">TypeIOError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'--cIO'</span>
<div class="viewcode-block" id="OperationError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.OperationError">[docs]</a><span class="k">class</span> <span class="nc">OperationError</span><span class="p">(</span><span class="n">DriverError</span><span class="p">):</span>
<span class="sd">"""</span>
<span class="sd"> An invalid operation on an interface element.</span>
<span class="sd"> """</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'--OPE'</span>
</div>
<span class="k">class</span> <span class="nc">TransactionError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="k">pass</span>
<span class="k">class</span> <span class="nc">SQLNotYetCompleteError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'03000'</span>
<span class="k">class</span> <span class="nc">ConnectionError</span><span class="p">(</span><span class="n">Error</span><span class="p">,</span> <span class="n">Disconnection</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'08000'</span>
<div class="viewcode-block" id="ConnectionDoesNotExistError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.ConnectionDoesNotExistError">[docs]</a><span class="k">class</span> <span class="nc">ConnectionDoesNotExistError</span><span class="p">(</span><span class="n">ConnectionError</span><span class="p">):</span>
<span class="sd">"""</span>
<span class="sd"> The connection is closed or was never connected.</span>
<span class="sd"> """</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'08003'</span></div>
<div class="viewcode-block" id="ConnectionFailureError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.ConnectionFailureError">[docs]</a><span class="k">class</span> <span class="nc">ConnectionFailureError</span><span class="p">(</span><span class="n">ConnectionError</span><span class="p">):</span>
<span class="s">'Raised when a connection is dropped'</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'08006'</span>
</div>
<div class="viewcode-block" id="ClientCannotConnectError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.ClientCannotConnectError">[docs]</a><span class="k">class</span> <span class="nc">ClientCannotConnectError</span><span class="p">(</span><span class="n">ConnectionError</span><span class="p">):</span>
<span class="sd">"""</span>
<span class="sd"> Client was unable to establish a connection to the server.</span>
<span class="sd"> """</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'08001'</span>
</div>
<span class="k">class</span> <span class="nc">ConnectionRejectionError</span><span class="p">(</span><span class="n">ConnectionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'08004'</span>
<span class="k">class</span> <span class="nc">TransactionResolutionUnknownError</span><span class="p">(</span><span class="n">ConnectionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'08007'</span>
<span class="k">class</span> <span class="nc">ProtocolError</span><span class="p">(</span><span class="n">ConnectionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'08P01'</span>
<span class="k">class</span> <span class="nc">TriggeredActionError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'09000'</span>
<div class="viewcode-block" id="FeatureError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.FeatureError">[docs]</a><span class="k">class</span> <span class="nc">FeatureError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"Unsupported feature"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'0A000'</span>
</div>
<span class="k">class</span> <span class="nc">TransactionInitiationError</span><span class="p">(</span><span class="n">TransactionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'0B000'</span>
<span class="k">class</span> <span class="nc">LocatorError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'0F000'</span>
<span class="k">class</span> <span class="nc">LocatorSpecificationError</span><span class="p">(</span><span class="n">LocatorError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'0F001'</span>
<span class="k">class</span> <span class="nc">GrantorError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'0L000'</span>
<span class="k">class</span> <span class="nc">GrantorOperationError</span><span class="p">(</span><span class="n">GrantorError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'0LP01'</span>
<span class="k">class</span> <span class="nc">RoleSpecificationError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'0P000'</span>
<span class="k">class</span> <span class="nc">CaseNotFoundError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'20000'</span>
<div class="viewcode-block" id="CardinalityError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.CardinalityError">[docs]</a><span class="k">class</span> <span class="nc">CardinalityError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"Wrong number of rows returned"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'21000'</span>
</div>
<span class="k">class</span> <span class="nc">TriggeredDataChangeViolation</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'27000'</span>
<span class="k">class</span> <span class="nc">AuthenticationSpecificationError</span><span class="p">(</span><span class="n">Error</span><span class="p">,</span> <span class="n">Disconnection</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'28000'</span>
<div class="viewcode-block" id="DPDSEError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.DPDSEError">[docs]</a><span class="k">class</span> <span class="nc">DPDSEError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"Dependent Privilege Descriptors Still Exist"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2B000'</span></div>
<span class="k">class</span> <span class="nc">DPDSEObjectError</span><span class="p">(</span><span class="n">DPDSEError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2BP01'</span>
<div class="viewcode-block" id="SREError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.SREError">[docs]</a><span class="k">class</span> <span class="nc">SREError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"SQL Routine Exception"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2F000'</span></div>
<span class="k">class</span> <span class="nc">FunctionExecutedNoReturnStatementError</span><span class="p">(</span><span class="n">SREError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2F005'</span>
<span class="k">class</span> <span class="nc">DataModificationProhibitedError</span><span class="p">(</span><span class="n">SREError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2F002'</span>
<span class="k">class</span> <span class="nc">StatementProhibitedError</span><span class="p">(</span><span class="n">SREError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2F003'</span>
<span class="k">class</span> <span class="nc">ReadingDataProhibitedError</span><span class="p">(</span><span class="n">SREError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2F004'</span>
<div class="viewcode-block" id="EREError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.EREError">[docs]</a><span class="k">class</span> <span class="nc">EREError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"External Routine Exception"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'38000'</span></div>
<span class="k">class</span> <span class="nc">ContainingSQLNotPermittedError</span><span class="p">(</span><span class="n">EREError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'38001'</span>
<span class="k">class</span> <span class="nc">ModifyingSQLDataNotPermittedError</span><span class="p">(</span><span class="n">EREError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'38002'</span>
<span class="k">class</span> <span class="nc">ProhibitedSQLStatementError</span><span class="p">(</span><span class="n">EREError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'38003'</span>
<span class="k">class</span> <span class="nc">ReadingSQLDataNotPermittedError</span><span class="p">(</span><span class="n">EREError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'38004'</span>
<div class="viewcode-block" id="ERIEError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.ERIEError">[docs]</a><span class="k">class</span> <span class="nc">ERIEError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"External Routine Invocation Exception"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'39000'</span></div>
<span class="k">class</span> <span class="nc">InvalidSQLState</span><span class="p">(</span><span class="n">ERIEError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'39001'</span>
<span class="k">class</span> <span class="nc">NullValueNotAllowed</span><span class="p">(</span><span class="n">ERIEError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'39004'</span>
<span class="k">class</span> <span class="nc">TriggerProtocolError</span><span class="p">(</span><span class="n">ERIEError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'39P01'</span>
<span class="k">class</span> <span class="nc">SRFProtocolError</span><span class="p">(</span><span class="n">ERIEError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'39P02'</span>
<div class="viewcode-block" id="TRError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.TRError">[docs]</a><span class="k">class</span> <span class="nc">TRError</span><span class="p">(</span><span class="n">TransactionError</span><span class="p">):</span>
<span class="s">"Transaction Rollback"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'40000'</span></div>
<span class="k">class</span> <span class="nc">DeadlockError</span><span class="p">(</span><span class="n">TRError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'40P01'</span>
<span class="k">class</span> <span class="nc">IntegrityConstraintViolationError</span><span class="p">(</span><span class="n">TRError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'40002'</span>
<span class="k">class</span> <span class="nc">SerializationError</span><span class="p">(</span><span class="n">TRError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'40001'</span>
<span class="k">class</span> <span class="nc">StatementCompletionUnknownError</span><span class="p">(</span><span class="n">TRError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'40003'</span>
<div class="viewcode-block" id="ITSError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.ITSError">[docs]</a><span class="k">class</span> <span class="nc">ITSError</span><span class="p">(</span><span class="n">TransactionError</span><span class="p">):</span>
<span class="s">"Invalid Transaction State"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'25000'</span></div>
<span class="k">class</span> <span class="nc">ActiveTransactionError</span><span class="p">(</span><span class="n">ITSError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'25001'</span>
<span class="k">class</span> <span class="nc">BranchAlreadyActiveError</span><span class="p">(</span><span class="n">ITSError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'25002'</span>
<span class="k">class</span> <span class="nc">BadAccessModeForBranchError</span><span class="p">(</span><span class="n">ITSError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'25003'</span>
<span class="k">class</span> <span class="nc">BadIsolationForBranchError</span><span class="p">(</span><span class="n">ITSError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'25004'</span>
<span class="k">class</span> <span class="nc">NoActiveTransactionForBranchError</span><span class="p">(</span><span class="n">ITSError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'25005'</span>
<div class="viewcode-block" id="ReadOnlyTransactionError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.ReadOnlyTransactionError">[docs]</a><span class="k">class</span> <span class="nc">ReadOnlyTransactionError</span><span class="p">(</span><span class="n">ITSError</span><span class="p">):</span>
<span class="s">"Occurs when an alteration occurs in a read-only transaction."</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'25006'</span></div>
<div class="viewcode-block" id="SchemaAndDataStatementsError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.SchemaAndDataStatementsError">[docs]</a><span class="k">class</span> <span class="nc">SchemaAndDataStatementsError</span><span class="p">(</span><span class="n">ITSError</span><span class="p">):</span>
<span class="s">"Mixed schema and data statements not allowed."</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'25007'</span></div>
<div class="viewcode-block" id="InconsistentCursorIsolationError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.InconsistentCursorIsolationError">[docs]</a><span class="k">class</span> <span class="nc">InconsistentCursorIsolationError</span><span class="p">(</span><span class="n">ITSError</span><span class="p">):</span>
<span class="s">"The held cursor requires the same isolation."</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'25008'</span>
</div>
<span class="k">class</span> <span class="nc">NoActiveTransactionError</span><span class="p">(</span><span class="n">ITSError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'25P01'</span>
<div class="viewcode-block" id="InFailedTransactionError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.InFailedTransactionError">[docs]</a><span class="k">class</span> <span class="nc">InFailedTransactionError</span><span class="p">(</span><span class="n">ITSError</span><span class="p">):</span>
<span class="s">"Occurs when an action occurs in a failed transaction."</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'25P02'</span>
</div>
<div class="viewcode-block" id="SavepointError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.SavepointError">[docs]</a><span class="k">class</span> <span class="nc">SavepointError</span><span class="p">(</span><span class="n">TransactionError</span><span class="p">):</span>
<span class="s">"Classification error designating errors that relate to savepoints."</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'3B000'</span></div>
<span class="k">class</span> <span class="nc">InvalidSavepointSpecificationError</span><span class="p">(</span><span class="n">SavepointError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'3B001'</span>
<span class="k">class</span> <span class="nc">TransactionTerminationError</span><span class="p">(</span><span class="n">TransactionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2D000'</span>
<div class="viewcode-block" id="IRError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.IRError">[docs]</a><span class="k">class</span> <span class="nc">IRError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"Insufficient Resource Error"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'53000'</span></div>
<span class="k">class</span> <span class="nc">MemoryError</span><span class="p">(</span><span class="n">IRError</span><span class="p">,</span> <span class="ne">MemoryError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'53200'</span>
<span class="k">class</span> <span class="nc">DiskFullError</span><span class="p">(</span><span class="n">IRError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'53100'</span>
<span class="k">class</span> <span class="nc">TooManyConnectionsError</span><span class="p">(</span><span class="n">IRError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'53300'</span>
<div class="viewcode-block" id="PLEError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.PLEError">[docs]</a><span class="k">class</span> <span class="nc">PLEError</span><span class="p">(</span><span class="ne">OverflowError</span><span class="p">):</span>
<span class="s">"Program Limit Exceeded"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'54000'</span></div>
<span class="k">class</span> <span class="nc">ComplexityOverflowError</span><span class="p">(</span><span class="n">PLEError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'54001'</span>
<span class="k">class</span> <span class="nc">ColumnOverflowError</span><span class="p">(</span><span class="n">PLEError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'54011'</span>
<span class="k">class</span> <span class="nc">ArgumentOverflowError</span><span class="p">(</span><span class="n">PLEError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'54023'</span>
<div class="viewcode-block" id="ONIPSError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.ONIPSError">[docs]</a><span class="k">class</span> <span class="nc">ONIPSError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"Object Not In Prerequisite State"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'55000'</span></div>
<span class="k">class</span> <span class="nc">ObjectInUseError</span><span class="p">(</span><span class="n">ONIPSError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'55006'</span>
<span class="k">class</span> <span class="nc">ImmutableRuntimeParameterError</span><span class="p">(</span><span class="n">ONIPSError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'55P02'</span>
<span class="k">class</span> <span class="nc">UnavailableLockError</span><span class="p">(</span><span class="n">ONIPSError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'55P03'</span>
<div class="viewcode-block" id="SEARVError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.SEARVError">[docs]</a><span class="k">class</span> <span class="nc">SEARVError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"Syntax Error or Access Rule Violation"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42000'</span>
</div>
<span class="k">class</span> <span class="nc">SEARVNameError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42602'</span>
<span class="k">class</span> <span class="nc">NameTooLongError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42622'</span>
<span class="k">class</span> <span class="nc">ReservedNameError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42939'</span>
<span class="k">class</span> <span class="nc">ForeignKeyCreationError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42830'</span>
<span class="k">class</span> <span class="nc">InsufficientPrivilegeError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42501'</span>
<span class="k">class</span> <span class="nc">GroupingError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42803'</span>
<span class="k">class</span> <span class="nc">RecursionError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P19'</span>
<span class="k">class</span> <span class="nc">WindowError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P20'</span>
<span class="k">class</span> <span class="nc">SyntaxError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42601'</span>
<span class="k">class</span> <span class="nc">TypeError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="k">pass</span>
<span class="k">class</span> <span class="nc">CoercionError</span><span class="p">(</span><span class="ne">TypeError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42846'</span>
<span class="k">class</span> <span class="nc">TypeMismatchError</span><span class="p">(</span><span class="ne">TypeError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42804'</span>
<span class="k">class</span> <span class="nc">IndeterminateTypeError</span><span class="p">(</span><span class="ne">TypeError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P18'</span>
<span class="k">class</span> <span class="nc">WrongObjectTypeError</span><span class="p">(</span><span class="ne">TypeError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42809'</span>
<span class="k">class</span> <span class="nc">UndefinedError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="k">pass</span>
<span class="k">class</span> <span class="nc">UndefinedColumnError</span><span class="p">(</span><span class="n">UndefinedError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42703'</span>
<span class="k">class</span> <span class="nc">UndefinedFunctionError</span><span class="p">(</span><span class="n">UndefinedError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42883'</span>
<span class="k">class</span> <span class="nc">UndefinedTableError</span><span class="p">(</span><span class="n">UndefinedError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P01'</span>
<span class="k">class</span> <span class="nc">UndefinedParameterError</span><span class="p">(</span><span class="n">UndefinedError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P02'</span>
<span class="k">class</span> <span class="nc">UndefinedObjectError</span><span class="p">(</span><span class="n">UndefinedError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42704'</span>
<span class="k">class</span> <span class="nc">DuplicateError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="k">pass</span>
<span class="k">class</span> <span class="nc">DuplicateColumnError</span><span class="p">(</span><span class="n">DuplicateError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42701'</span>
<span class="k">class</span> <span class="nc">DuplicateCursorError</span><span class="p">(</span><span class="n">DuplicateError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P03'</span>
<span class="k">class</span> <span class="nc">DuplicateDatabaseError</span><span class="p">(</span><span class="n">DuplicateError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P04'</span>
<span class="k">class</span> <span class="nc">DuplicateFunctionError</span><span class="p">(</span><span class="n">DuplicateError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42723'</span>
<span class="k">class</span> <span class="nc">DuplicatePreparedStatementError</span><span class="p">(</span><span class="n">DuplicateError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P05'</span>
<span class="k">class</span> <span class="nc">DuplicateSchemaError</span><span class="p">(</span><span class="n">DuplicateError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P06'</span>
<span class="k">class</span> <span class="nc">DuplicateTableError</span><span class="p">(</span><span class="n">DuplicateError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P07'</span>
<span class="k">class</span> <span class="nc">DuplicateAliasError</span><span class="p">(</span><span class="n">DuplicateError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42712'</span>
<span class="k">class</span> <span class="nc">DuplicateObjectError</span><span class="p">(</span><span class="n">DuplicateError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42710'</span>
<span class="k">class</span> <span class="nc">AmbiguityError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="k">pass</span>
<span class="k">class</span> <span class="nc">AmbiguousColumnError</span><span class="p">(</span><span class="n">AmbiguityError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42702'</span>
<span class="k">class</span> <span class="nc">AmbiguousFunctionError</span><span class="p">(</span><span class="n">AmbiguityError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42725'</span>
<span class="k">class</span> <span class="nc">AmbiguousParameterError</span><span class="p">(</span><span class="n">AmbiguityError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P08'</span>
<span class="k">class</span> <span class="nc">AmbiguousAliasError</span><span class="p">(</span><span class="n">AmbiguityError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P09'</span>
<span class="k">class</span> <span class="nc">ColumnReferenceError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P10'</span>
<span class="k">class</span> <span class="nc">DefinitionError</span><span class="p">(</span><span class="n">SEARVError</span><span class="p">):</span>
<span class="k">pass</span>
<span class="k">class</span> <span class="nc">ColumnDefinitionError</span><span class="p">(</span><span class="n">DefinitionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42611'</span>
<span class="k">class</span> <span class="nc">CursorDefinitionError</span><span class="p">(</span><span class="n">DefinitionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P11'</span>
<span class="k">class</span> <span class="nc">DatabaseDefinitionError</span><span class="p">(</span><span class="n">DefinitionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P12'</span>
<span class="k">class</span> <span class="nc">FunctionDefinitionError</span><span class="p">(</span><span class="n">DefinitionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P13'</span>
<span class="k">class</span> <span class="nc">PreparedStatementDefinitionError</span><span class="p">(</span><span class="n">DefinitionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P14'</span>
<span class="k">class</span> <span class="nc">SchemaDefinitionError</span><span class="p">(</span><span class="n">DefinitionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P15'</span>
<span class="k">class</span> <span class="nc">TableDefinitionError</span><span class="p">(</span><span class="n">DefinitionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P16'</span>
<span class="k">class</span> <span class="nc">ObjectDefinitionError</span><span class="p">(</span><span class="n">DefinitionError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'42P17'</span>
<span class="k">class</span> <span class="nc">CursorStateError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'24000'</span>
<span class="k">class</span> <span class="nc">WithCheckOptionError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'44000'</span>
<span class="k">class</span> <span class="nc">NameError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="k">pass</span>
<span class="k">class</span> <span class="nc">CatalogNameError</span><span class="p">(</span><span class="ne">NameError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'3D000'</span>
<span class="k">class</span> <span class="nc">CursorNameError</span><span class="p">(</span><span class="ne">NameError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'34000'</span>
<span class="k">class</span> <span class="nc">StatementNameError</span><span class="p">(</span><span class="ne">NameError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'26000'</span>
<span class="k">class</span> <span class="nc">SchemaNameError</span><span class="p">(</span><span class="ne">NameError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'3F000'</span>
<div class="viewcode-block" id="ICVError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.ICVError">[docs]</a><span class="k">class</span> <span class="nc">ICVError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"Integrity Contraint Violation"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'23000'</span></div>
<span class="k">class</span> <span class="nc">RestrictError</span><span class="p">(</span><span class="n">ICVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'23001'</span>
<span class="k">class</span> <span class="nc">NotNullError</span><span class="p">(</span><span class="n">ICVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'23502'</span>
<span class="k">class</span> <span class="nc">ForeignKeyError</span><span class="p">(</span><span class="n">ICVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'23503'</span>
<span class="k">class</span> <span class="nc">UniqueError</span><span class="p">(</span><span class="n">ICVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'23505'</span>
<span class="k">class</span> <span class="nc">CheckError</span><span class="p">(</span><span class="n">ICVError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'23514'</span>
<span class="k">class</span> <span class="nc">DataError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22000'</span>
<span class="k">class</span> <span class="nc">StringRightTruncationError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22001'</span>
<span class="k">class</span> <span class="nc">StringDataLengthError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22026'</span>
<span class="k">class</span> <span class="nc">ZeroLengthString</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2200F'</span>
<span class="k">class</span> <span class="nc">EncodingError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22021'</span>
<span class="k">class</span> <span class="nc">ArrayElementError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2202E'</span>
<span class="k">class</span> <span class="nc">SpecificTypeMismatch</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2200G'</span>
<span class="k">class</span> <span class="nc">NullValueNotAllowedError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22004'</span>
<span class="k">class</span> <span class="nc">NullValueNoIndicatorParameter</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22002'</span>
<span class="k">class</span> <span class="nc">ZeroDivisionError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22012'</span>
<span class="k">class</span> <span class="nc">FloatingPointError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22P01'</span>
<span class="k">class</span> <span class="nc">AssignmentError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22005'</span>
<span class="k">class</span> <span class="nc">IndicatorOverflowError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22022'</span>
<span class="k">class</span> <span class="nc">BadCopyError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22P04'</span>
<span class="k">class</span> <span class="nc">TextRepresentationError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22P02'</span>
<span class="k">class</span> <span class="nc">BinaryRepresentationError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22P03'</span>
<span class="k">class</span> <span class="nc">UntranslatableCharacterError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22P05'</span>
<span class="k">class</span> <span class="nc">NonstandardUseOfEscapeCharacterError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22P06'</span>
<span class="k">class</span> <span class="nc">NotXMLError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2200L'</span>
<span class="k">class</span> <span class="nc">XMLDocumentError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2200M'</span>
<span class="k">class</span> <span class="nc">XMLContentError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2200N'</span>
<span class="k">class</span> <span class="nc">XMLCommentError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2200S'</span>
<span class="k">class</span> <span class="nc">XMLProcessingInstructionError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2200T'</span>
<span class="k">class</span> <span class="nc">DateTimeFormatError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22007'</span>
<span class="k">class</span> <span class="nc">TimeZoneDisplacementValueError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22009'</span>
<span class="k">class</span> <span class="nc">DateTimeFieldOverflowError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22008'</span>
<span class="k">class</span> <span class="nc">IntervalFieldOverflowError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22015'</span>
<span class="k">class</span> <span class="nc">LogArgumentError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2201E'</span>
<span class="k">class</span> <span class="nc">PowerFunctionArgumentError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2201F'</span>
<span class="k">class</span> <span class="nc">WidthBucketFunctionArgumentError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2201G'</span>
<span class="k">class</span> <span class="nc">CastCharacterValueError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22018'</span>
<span class="k">class</span> <span class="nc">EscapeCharacterError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22019'</span>
<span class="k">class</span> <span class="nc">EscapeOctetError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2200D'</span>
<span class="k">class</span> <span class="nc">EscapeSequenceError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22025'</span>
<span class="k">class</span> <span class="nc">EscapeCharacterConflictError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2200B'</span>
<div class="viewcode-block" id="EscapeCharacterError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.EscapeCharacterError">[docs]</a><span class="k">class</span> <span class="nc">EscapeCharacterError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="s">"Invalid escape character"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2200C'</span>
</div>
<span class="k">class</span> <span class="nc">SubstringError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22011'</span>
<span class="k">class</span> <span class="nc">TrimError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22027'</span>
<span class="k">class</span> <span class="nc">IndicatorParameterValueError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22010'</span>
<span class="k">class</span> <span class="nc">LimitValueError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2201W'</span>
<span class="n">pg_code</span> <span class="o">=</span> <span class="s">'22020'</span>
<span class="k">class</span> <span class="nc">OffsetValueError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2201X'</span>
<span class="k">class</span> <span class="nc">ParameterValueError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22023'</span>
<span class="k">class</span> <span class="nc">RegularExpressionError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'2201B'</span>
<span class="k">class</span> <span class="nc">NumericRangeError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22003'</span>
<span class="k">class</span> <span class="nc">UnterminatedCStringError</span><span class="p">(</span><span class="n">DataError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'22024'</span>
<span class="k">class</span> <span class="nc">InternalError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'XX000'</span>
<span class="k">class</span> <span class="nc">DataCorruptedError</span><span class="p">(</span><span class="n">InternalError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'XX001'</span>
<span class="k">class</span> <span class="nc">IndexCorruptedError</span><span class="p">(</span><span class="n">InternalError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'XX002'</span>
<div class="viewcode-block" id="SIOError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.SIOError">[docs]</a><span class="k">class</span> <span class="nc">SIOError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"System I/O"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'58000'</span></div>
<span class="k">class</span> <span class="nc">UndefinedFileError</span><span class="p">(</span><span class="n">SIOError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'58P01'</span>
<span class="k">class</span> <span class="nc">DuplicateFileError</span><span class="p">(</span><span class="n">SIOError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'58P02'</span>
<div class="viewcode-block" id="CFError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.CFError">[docs]</a><span class="k">class</span> <span class="nc">CFError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"Configuration File Error"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'F0000'</span></div>
<span class="k">class</span> <span class="nc">LockFileExistsError</span><span class="p">(</span><span class="n">CFError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'F0001'</span>
<div class="viewcode-block" id="OIError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.OIError">[docs]</a><span class="k">class</span> <span class="nc">OIError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"Operator Intervention"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'57000'</span></div>
<span class="k">class</span> <span class="nc">QueryCanceledError</span><span class="p">(</span><span class="n">OIError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'57014'</span>
<span class="k">class</span> <span class="nc">AdminShutdownError</span><span class="p">(</span><span class="n">OIError</span><span class="p">,</span> <span class="n">Disconnection</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'57P01'</span>
<span class="k">class</span> <span class="nc">CrashShutdownError</span><span class="p">(</span><span class="n">OIError</span><span class="p">,</span> <span class="n">Disconnection</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'57P02'</span>
<div class="viewcode-block" id="ServerNotReadyError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.ServerNotReadyError">[docs]</a><span class="k">class</span> <span class="nc">ServerNotReadyError</span><span class="p">(</span><span class="n">OIError</span><span class="p">,</span> <span class="n">Disconnection</span><span class="p">):</span>
<span class="s">'Thrown when a connection is established to a server that is still starting up.'</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'57P03'</span>
</div>
<div class="viewcode-block" id="PLPGSQLError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.PLPGSQLError">[docs]</a><span class="k">class</span> <span class="nc">PLPGSQLError</span><span class="p">(</span><span class="n">Error</span><span class="p">):</span>
<span class="s">"Error raised by a PL/PgSQL procedural function"</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'P0000'</span></div>
<div class="viewcode-block" id="PLPGSQLRaiseError"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.PLPGSQLRaiseError">[docs]</a><span class="k">class</span> <span class="nc">PLPGSQLRaiseError</span><span class="p">(</span><span class="n">PLPGSQLError</span><span class="p">):</span>
<span class="s">"Error raised by a PL/PgSQL RAISE statement."</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'P0001'</span></div>
<span class="k">class</span> <span class="nc">PLPGSQLNoDataFoundError</span><span class="p">(</span><span class="n">PLPGSQLError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'P0002'</span>
<span class="k">class</span> <span class="nc">PLPGSQLTooManyRowsError</span><span class="p">(</span><span class="n">PLPGSQLError</span><span class="p">):</span>
<span class="n">code</span> <span class="o">=</span> <span class="s">'P0003'</span>
<span class="c"># Setup mapping to provide code based exception lookup.</span>
<span class="n">code_to_error</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">code_to_warning</span> <span class="o">=</span> <span class="p">{}</span>
<div class="viewcode-block" id="map_errors_and_warnings"><a class="viewcode-back" href="../../reference.html#postgresql.exceptions.map_errors_and_warnings">[docs]</a><span class="k">def</span> <span class="nf">map_errors_and_warnings</span><span class="p">(</span>
<span class="n">objs</span> <span class="p">:</span> <span class="s">"A iterable of `Warning`s and `Error`'s"</span><span class="p">,</span>
<span class="n">error_container</span> <span class="p">:</span> <span class="s">"apply the code to error association to this object"</span> <span class="o">=</span> <span class="n">code_to_error</span><span class="p">,</span>
<span class="n">warning_container</span> <span class="p">:</span> <span class="s">"apply the code to warning association to this object"</span> <span class="o">=</span> <span class="n">code_to_warning</span><span class="p">,</span>
<span class="p">):</span>
<span class="sd">"""</span>
<span class="sd"> Construct the code-to-error and code-to-warning associations.</span>
<span class="sd"> """</span>
<span class="k">for</span> <span class="n">obj</span> <span class="ow">in</span> <span class="n">objs</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="nb">issubclass</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">obj</span><span class="p">),</span> <span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="ne">Warning</span><span class="p">),</span> <span class="nb">type</span><span class="p">(</span><span class="n">Error</span><span class="p">))):</span>
<span class="c"># It's not object of interest.</span>
<span class="k">continue</span>
<span class="n">code</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="s">'code'</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>
<span class="k">if</span> <span class="n">code</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="c"># It has no code attribute, or the code was set to None.</span>
<span class="c"># If it's code is None, we don't map it as it's a "container".</span>
<span class="k">continue</span>
<span class="k">if</span> <span class="nb">issubclass</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">Error</span><span class="p">):</span>
<span class="n">base</span> <span class="o">=</span> <span class="n">Error</span>
<span class="n">container</span> <span class="o">=</span> <span class="n">error_container</span>
<span class="k">elif</span> <span class="nb">issubclass</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="ne">Warning</span><span class="p">):</span>
<span class="n">base</span> <span class="o">=</span> <span class="ne">Warning</span>
<span class="n">container</span> <span class="o">=</span> <span class="n">warning_container</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">continue</span>
<span class="n">cur_obj</span> <span class="o">=</span> <span class="n">container</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">code</span><span class="p">)</span>
<span class="k">if</span> <span class="n">cur_obj</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">or</span> <span class="nb">issubclass</span><span class="p">(</span><span class="n">cur_obj</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span>
<span class="c"># There is no object yet, or the object at the code</span>
<span class="c"># is not the most general class.</span>
<span class="c"># The latter condition comes into play when</span>
<span class="c"># there are sub-Class types that share the Class code</span>
<span class="c"># with the most general type. (See TypeError)</span>
<span class="n">container</span><span class="p">[</span><span class="n">code</span><span class="p">]</span> <span class="o">=</span> <span class="n">obj</span>
<span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="s">'pg_code'</span><span class="p">):</span>
<span class="c"># If there's a PostgreSQL version of the code,</span>
<span class="c"># map it as well for older servers.</span>
<span class="n">container</span><span class="p">[</span><span class="n">obj</span><span class="o">.</span><span class="n">pg_code</span><span class="p">]</span> <span class="o">=</span> <span class="n">obj</span>
</div>
<span class="k">def</span> <span class="nf">code_lookup</span><span class="p">(</span>
<span class="n">default</span> <span class="p">:</span> <span class="s">"The object to return when no code or class is found"</span><span class="p">,</span>
<span class="n">container</span> <span class="p">:</span> <span class="s">"where to look for the object associated with the code"</span><span class="p">,</span>
<span class="n">code</span> <span class="p">:</span> <span class="s">"the code to find the exception for"</span>
<span class="p">):</span>
<span class="n">obj</span> <span class="o">=</span> <span class="n">container</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">code</span><span class="p">)</span>
<span class="k">if</span> <span class="n">obj</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">obj</span> <span class="o">=</span> <span class="n">container</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">code</span><span class="p">[:</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="s">"000"</span><span class="p">,</span> <span class="n">default</span><span class="p">)</span>
<span class="k">return</span> <span class="n">obj</span>
<span class="n">map_errors_and_warnings</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">[</span><span class="n">__name__</span><span class="p">]</span><span class="o">.</span><span class="n">__dict__</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
<span class="n">ErrorLookup</span> <span class="o">=</span> <span class="n">partial</span><span class="p">(</span><span class="n">code_lookup</span><span class="p">,</span> <span class="n">Error</span><span class="p">,</span> <span class="n">code_to_error</span><span class="p">)</span>
<span class="n">WarningLookup</span> <span class="o">=</span> <span class="n">partial</span><span class="p">(</span><span class="n">code_lookup</span><span class="p">,</span> <span class="ne">Warning</span><span class="p">,</span> <span class="n">code_to_warning</span><span class="p">)</span>
<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">'__main__'</span><span class="p">:</span>
<span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
<span class="k">if</span> <span class="n">x</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">'01'</span><span class="p">):</span>
<span class="n">e</span> <span class="o">=</span> <span class="n">WarningLookup</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">e</span> <span class="o">=</span> <span class="n">ErrorLookup</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">'postgresql.exceptions.</span><span class="si">%s</span><span class="s"> [</span><span class="si">%s</span><span class="s">]</span><span class="si">%s%s</span><span class="s">'</span> <span class="o">%</span><span class="p">(</span>
<span class="n">e</span><span class="o">.</span><span class="n">__name__</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">code</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">linesep</span><span class="p">,</span> <span class="p">(</span>
<span class="n">e</span><span class="o">.</span><span class="n">__doc__</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">linesep</span><span class="o">.</span><span class="n">join</span><span class="p">([</span>
<span class="s">' '</span> <span class="o">+</span> <span class="n">x</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">__doc__</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">'</span><span class="se">\n</span><span class="s">'</span><span class="p">)</span>
<span class="p">])</span> <span class="o">+</span> <span class="n">os</span><span class="o">.</span><span class="n">linesep</span> <span class="ow">or</span> <span class="s">''</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="c">##</span>
<span class="c"># vim: ts=3:sw=3:noet:</span>
</pre></div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<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><a href="../../index.html">py-postgresql 1.1.0 documentation</a> »</li>
<li><a href="../index.html" >Module code</a> »</li>
<li><a href="../postgresql.html" >postgresql</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright Python+Postgres.
Last updated on Mar 31, 2014.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
</div>
</body>
</html>
|