Skip to content

API Reference parrot.tools.databasequery.sources.mssql

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

parrot.tools.databasequery.sources.mssql

View source

Microsoft SQL Server database source for DatabaseToolkit.

Implements AbstractDatabaseSource for MSSQL using the asyncdb mssql driver. Overrides validate_query() to allow EXEC/EXECUTE statements (stored procedures) in addition to standard T-SQL. Includes stored procedures in metadata discovery.

Part of FEAT-062 — DatabaseToolkit.

Alias AbstractDatabaseSource

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

Alias ColumnMeta

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

Class MSSQLSource

Microsoft SQL Server database source with stored procedure support.

Uses the asyncdb mssql driver. Validates queries with the tsql sqlglot dialect, with special handling for EXEC/EXECUTE stored procedure calls. Exposes stored procedures alongside tables in metadata discovery.

Method MSSQLSource.get_default_credentials

Return default MSSQL credentials from environment variables.

Reads MSSQL_HOST, MSSQL_PORT, MSSQL_DATABASE, MSSQL_USER, MSSQL_PASSWORD from navconfig via the expanded interface function.

get_default_credentials() -> dict[str, Any]

Returns: dict[str, Any] — Dict with MSSQL connection parameters, or empty dict if no env vars are configured.

Method MSSQLSource.validate_query

Validate a T-SQL query, including EXEC/EXECUTE statements.

EXEC and EXECUTE are valid MSSQL stored procedure calls. The base sqlglot validation may reject them, so we pre-check for this pattern and return valid=True immediately for SP invocations.

Standard SELECT/INSERT/UPDATE/DELETE queries are validated via the base class using the tsql sqlglot dialect.

validate_query(query: str) -> ValidationResult

Parameter Type Default Description
query str T-SQL query string or EXEC/EXECUTE statement.

Returns: ValidationResult — ValidationResult indicating whether the query is valid.

Method MSSQLSource.get_metadata

Discover MSSQL schema, including tables and stored procedures.

Queries both INFORMATION_SCHEMA.COLUMNS for table metadata and sys.procedures/sys.parameters for stored procedure metadata. Stored procedures are returned as TableMeta entries with schema_name="stored_procedures".

get_metadata(credentials: dict[str, Any], tables: list[str] | None = None) -> MetadataResult

Parameter Type Default Description
credentials dict[str, Any] Connection credentials.
tables list[str] | None None Optional list of specific table names to inspect.

Returns: MetadataResult — MetadataResult with table, column, and stored procedure metadata.

Method MSSQLSource.query

Execute a T-SQL query or stored procedure call.

Supports both standard SELECT statements and EXEC/EXECUTE calls.

query(credentials: dict[str, Any], sql: str, params: dict[str, Any] | None = None) -> QueryResult

Parameter Type Default Description
credentials dict[str, Any] Connection credentials.
sql str T-SQL query or EXEC statement.
params dict[str, Any] | None None Optional query parameters.

Returns: QueryResult — QueryResult with rows and execution metadata.

Method MSSQLSource.query_row

Execute a T-SQL query and return the first row.

query_row(credentials: dict[str, Any], sql: str, params: dict[str, Any] | None = None) -> RowResult

Parameter Type Default Description
credentials dict[str, Any] Connection credentials.
sql str T-SQL query string.
params dict[str, Any] | None None Optional query parameters.

Returns: RowResult — RowResult with a single row or found=False.

Alias MetadataResult

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

Alias QueryResult

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

Alias RowResult

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

Alias TableMeta

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

Alias ValidationResult

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

Alias register_source

Re-exported from parrot.tools.databasequery.sources.register_source.

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