Skip to content

Database

Database

Database(url, match_schema=None, match_tables=None, **kwargs)

Natural language interface for databases.

Supports 15+ database types including PostgreSQL, MySQL, SQLite, Snowflake, BigQuery.

PARAMETER DESCRIPTION
url

Database connection URL (e.g., 'postgresql://user:pass@host/db')

TYPE: str

match_schema

Regex pattern to filter schemas. Mutually exclusive with match_tables.

TYPE: str DEFAULT: None

match_tables

Regex pattern to filter tables. Mutually exclusive with match_schema.

TYPE: str DEFAULT: None

ask

ask(prompt, model=None, context=None, output_type=None, stream=False)

Ask natural language questions and get structured responses.

PARAMETER DESCRIPTION
prompt

Natural language question or instruction.

TYPE: str

model

AI model to use (e.g., 'openai:gpt-4', 'anthropic:claude-3-5-sonnet').

TYPE: str DEFAULT: None

context

Additional business context for better responses.

TYPE: str DEFAULT: None

output_type

Pydantic model for structured responses.

TYPE: BaseModel DEFAULT: None

stream

Show live AI reasoning in terminal.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
Any

Response matching the requested output type.

tools

tools()

Available tool methods for database operations.

RETURNS DESCRIPTION
list[callable]

Methods for table inspection and query execution.

instructions

instructions(context=None)

Generate system instructions for AI agents.

PARAMETER DESCRIPTION
context

Additional business context to include in instructions.

TYPE: str DEFAULT: None

RETURNS DESCRIPTION
str

System instructions for AI interaction with this datasource.