sqlite_failure_kind (guard/sqlite_errors.py)

hol-guard · src/codex_plugin_scanner/guard/sqlite_errors.py · python · Apache-2.0
database

Utility to classify SQLite errors into failure kinds for retry logic.

# Source: https://github.com/hashgraph-online/hol-guard | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""SQLite failure routing with authoritative primary and extended codes."""

from __future__ import annotations

import sqlite3
from typing import Final, Literal

SQLiteFailureKind = Literal["busy", "locked", "io", "full", "corrupt", "other"]
FATAL_SQLITE_ERROR_MARKERS = (
    "database disk image is malformed",
    "database corruption",
    "file is not a database",
)
SQLITE_IO_ERROR_MARKER = "disk i/o error"
# SQLite's stable primary result codes; named sqlite3 exports require Python
# 3.11, while Guard also supports 3.10 and its text-only exceptions.
_SQLITE_BUSY: Final = 5
_

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key