|
1 | 1 | # This file is from sqlite-utils and copyright and license is the same as that project |
2 | 2 | __all__ = ['Database', 'Queryable', 'Table', 'View'] |
3 | 3 |
|
4 | | -from .utils import chunks, hash_record, OperationalError, suggest_column_types, types_for_column_types, column_affinity, find_spatialite |
| 4 | +from .utils import chunks, hash_record, suggest_column_types, types_for_column_types, column_affinity, find_spatialite |
5 | 5 | from collections import namedtuple |
6 | 6 | from collections.abc import Mapping |
7 | 7 | from typing import cast, Any, Callable, Dict, Generator, Iterable, Union, Optional, List, Tuple, Iterator |
8 | 8 | from functools import cache |
9 | 9 | import contextlib, datetime, decimal, inspect, itertools, json, os, pathlib, re, secrets, textwrap, binascii, uuid, logging |
10 | | -import apsw.ext, apsw.bestpractice |
| 10 | +import apsw, apsw.ext, apsw.bestpractice |
11 | 11 |
|
12 | 12 | logger = logging.getLogger('apsw') |
13 | 13 | logger.setLevel(logging.ERROR) |
@@ -684,7 +684,7 @@ def cached_counts(self, tables: Optional[Iterable[str]] = None) -> Dict[str, int |
684 | 684 | sql += " where [table] in ({})".format(", ".join("?" for table in tables)) |
685 | 685 | try: |
686 | 686 | return {r[0]: r[1] for r in self.execute(sql, tables).fetchall()} |
687 | | - except OperationalError: |
| 687 | + except apsw.Error: |
688 | 688 | return {} |
689 | 689 |
|
690 | 690 | def reset_counts(self): |
@@ -2118,7 +2118,7 @@ def create_index( |
2118 | 2118 | try: |
2119 | 2119 | self.db.execute(sql) |
2120 | 2120 | break |
2121 | | - except OperationalError as e: |
| 2121 | + except apsw.SQLError as e: |
2122 | 2122 | # find_unique_name=True - try again if 'index ... already exists' |
2123 | 2123 | arg = e.args[0] |
2124 | 2124 | if ( |
@@ -2769,7 +2769,7 @@ def update( |
2769 | 2769 |
|
2770 | 2770 | for row in cursor: |
2771 | 2771 | self.result.append(dict(zip(columns, row))) |
2772 | | - except OperationalError as e: |
| 2772 | + except apsw.SQLError as e: |
2773 | 2773 | if alter and (" column" in e.args[0]): |
2774 | 2774 | # Attempt to add any missing columns, then try again |
2775 | 2775 | self.add_missing_columns([updates]) |
@@ -2934,7 +2934,7 @@ def insert_chunk( |
2934 | 2934 | except apsw.ExecutionCompleteError: continue |
2935 | 2935 | for row in cursor: |
2936 | 2936 | records.append(dict(zip(columns, row))) |
2937 | | - except OperationalError as e: |
| 2937 | + except apsw.SQLError as e: |
2938 | 2938 | if alter and (" column" in e.args[0]): |
2939 | 2939 | # Attempt to add any missing columns, then try again |
2940 | 2940 | self.add_missing_columns(chunk) |
|
0 commit comments