mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-16 16:14:28 -04:00
sqlite search: check SQLite version when indexing
If creating the FTS5 tables fails due to a known version incompatiblity, report the required version to the user.
This commit is contained in:
parent
1e604a1352
commit
9b85f35b63
1 changed files with 17 additions and 6 deletions
|
@ -75,12 +75,23 @@ def _create_tables():
|
||||||
with get_connection() as cursor:
|
with get_connection() as cursor:
|
||||||
# Create a contentless-delete FTS5 table that indexes
|
# Create a contentless-delete FTS5 table that indexes
|
||||||
# but does not store the texts of snapshots
|
# but does not store the texts of snapshots
|
||||||
cursor.execute(
|
try:
|
||||||
f"CREATE VIRTUAL TABLE {table}"
|
cursor.execute(
|
||||||
f" USING fts5({column},"
|
f"CREATE VIRTUAL TABLE {table}"
|
||||||
f" tokenize={tokenizers},"
|
f" USING fts5({column},"
|
||||||
" content='', contentless_delete=1);"
|
f" tokenize={tokenizers},"
|
||||||
)
|
" content='', contentless_delete=1);"
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
msg = str(e)
|
||||||
|
if 'unrecognized option: "contentlessdelete"' in msg:
|
||||||
|
sqlite_version = getattr(sqlite3, "sqlite_version", "Unknown")
|
||||||
|
raise RuntimeError(
|
||||||
|
"SQLite full-text search requires SQLite >= 3.43.0;"
|
||||||
|
f" the running version is {sqlite_version}"
|
||||||
|
) from e
|
||||||
|
else:
|
||||||
|
raise
|
||||||
# Create a one-to-one mapping between ArchiveBox snapshot_id
|
# Create a one-to-one mapping between ArchiveBox snapshot_id
|
||||||
# and FTS5 rowid, because the column type of rowid can't be
|
# and FTS5 rowid, because the column type of rowid can't be
|
||||||
# customized.
|
# customized.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue