zylon-ai/private-gpt · error · ImportError
Database query dependencies are not installed. Install with
Error message
Database query dependencies are not installed. Install with one of: `uv sync --inexact --extra database-postgres` or `uv sync --inexact --extra database-mysql` or `uv sync --inexact --extra database-mssql` or `uv sync --inexact --extra database-db2` or `uv sync --inexact --extra database`.
What it means
Raised at module import time of database_query_generator.py when the sqlglot package cannot be imported. sqlglot powers SQL parsing/transpilation and is optional, distributed via the database extras (postgres/mysql/mssql/db2 or the umbrella 'database' extra). Because it fails at import, the error surfaces as soon as the tabular/database-query module is loaded, with the exact uv sync commands listed in the message.
Source
Thrown at private_gpt/components/tabular/database_query_generator.py:68
from private_gpt.di import get_global_injector
from private_gpt.events.models import TextBlock
from private_gpt.utils.dependencies import format_missing_dependency_message
if TYPE_CHECKING:
from sqlalchemy import Row
logger = logging.getLogger(__name__)
try:
import sqlglot # type: ignore[import-not-found] # ty:ignore[unresolved-import]
from sqlglot import ( # ty:ignore[unresolved-import]
Dialects, # type: ignore[import-not-found]
)
from sqlglot.errors import ( # ty:ignore[unresolved-import]
ParseError, # type: ignore[import-not-found]
)
except (ImportError, ModuleNotFoundError) as e:
raise ImportError(
format_missing_dependency_message(
"Database query",
extras=(
"database-postgres",
"database-mysql",
"database-mssql",
"database-db2",
"database",
),
)
) from e
@functools.cache
def _load_ibm_db() -> Any:
try:
import ibm_db # type: ignore[import-not-found] # ty:ignore[unresolved-import]
except ImportError as e:View on GitHub (pinned to 4a030776a3)
Solutions
- Install one extra matching your DB: uv sync --inexact --extra database-postgres (or database-mysql / database-mssql / database-db2), or the umbrella: uv sync --inexact --extra database
- Verify: python -c "import sqlglot"
- If you do not need database queries, disable the feature so the module is never imported
Example fix
# terminal — before: import fails with ImportError uv sync --inexact --extra database-postgres # after: import private_gpt.components.tabular.database_query_generator works
Defensive patterns
Strategy: validation
Validate before calling
try:
import sqlglot # noqa: F401
except ImportError:
raise SystemExit(
"database query requires sqlglot: "
"uv sync --inexact --extra database-postgres"
)
from private_gpt.components.tabular.database_query_generator import ( # noqa: F401
DatabaseQueryGenerator,
) Type guard
def database_query_available() -> bool:
try:
import sqlglot # noqa: F401
return True
except ImportError:
return False Prevention
- Import the tabular module lazily and guard with importlib.util.find_spec('sqlglot')
- Install at least one database extra in every environment that enables the feature
When it happens
Trigger: Importing private_gpt.components.tabular.database_query_generator (directly or via enabling database-query features) in an environment where sqlglot is not installed.
Common situations: Enabling the tabular/database query feature on a deployment installed without any database extra; CI or Docker images built from a minimal dependency set; local venv synced before the feature was toggled on.
Related errors
- DB2 database query dependencies are not installed. Install w
- DB2 database query dependencies are not installed. Install w
- OpenAI embeddings dependencies are not installed. Install wi
- OpenAI-like Embeddings dependencies are not installed. Insta
- Harmony parser dependencies are not installed. Install with
AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15).
Data as JSON: /api/errors/0542fa95f195fbfa.
Report an issue: GitHub.