Skip to content

API Reference parrot.tools.databasequery.sources

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.databasequery.sources

View source

DatabaseToolkit — Source Registry & Driver Alias Resolution.

Provides a pluggable registry for database source implementations. Sources self-register via the @register_source(driver) decorator. The normalize_driver() function maps all known aliases to their canonical driver names before registry lookup.

Part of FEAT-062 — DatabaseToolkit.

Alias AbstractDatabaseSource

Re-exported from parrot.tools.databasequery.base.AbstractDatabaseSource.

Function get_source_class

Look up a registered database source class by driver name.

Resolves aliases via normalize_driver() before lookup. Lazily imports all source modules on first call.

get_source_class(driver: str) -> type[AbstractDatabaseSource]

Parameter Type Default Description
driver str Driver name or alias (e.g., 'pg', 'postgresql').

Returns: type[AbstractDatabaseSource] — The registered AbstractDatabaseSource subclass.

Raises:

  • ValueError — If no source is registered for the given driver.

Function normalize_driver

Map driver aliases to their canonical names.

This function is idempotent: passing a canonical driver name returns the same name unchanged.

normalize_driver(driver: str) -> str

Parameter Type Default Description
driver str Driver name or alias (case-insensitive).

Returns: str — Canonical driver name.

Function register_source

Decorator that registers a database source class in the registry.

The driver parameter should be the canonical driver name (e.g., 'pg', not 'postgres'). Aliases are resolved via normalize_driver() before lookup.

register_source(driver: str) -> Callable[[type], type]

Parameter Type Default Description
driver str Canonical driver name to register the source under.

Returns: Callable[[type], type] — Class decorator that registers the source and returns the class unchanged.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally