Adapters API Reference
Complete API documentation for all database adapters and grounding functions.Adapter Classes
All adapters extend theAdapter base class and implement database-specific behavior.
Sqlite
defaultSchema:undefinedsystemSchemas:[]formatterLanguage:'sqlite'
Postgres
defaultSchema:'public'systemSchemas:['pg_catalog', 'information_schema']formatterLanguage:'postgresql'
SqlServer
defaultSchema:'dbo'systemSchemas:['INFORMATION_SCHEMA', 'sys']formatterLanguage:'transactsql'
Mysql / Mariadb
defaultSchema:undefinedsystemSchemas:['mysql', 'information_schema', 'performance_schema', 'sys']formatterLanguage:'mysql'
BigQuery
defaultSchema: First dataset if only one providedsystemSchemas:[]formatterLanguage:'bigquery'
Grounding Functions
Grounding functions control schema introspection. All adapters support these:tables()
Introspect tables, columns, and data types.views()
Introspect database views.info()
Provide database version and metadata.indexes()
Introspect table indexes.- Index name
- Columns in index
- Unique constraint
- Index type (btree, hash, gin, gist)
constraints()
Introspect table constraints.PRIMARY_KEYFOREIGN_KEYUNIQUECHECKNOT_NULLDEFAULT
rowCount()
Count rows and classify table sizes.tiny: < 100 rowssmall: 100-999 rowsmedium: 1,000-9,999 rowslarge: 10,000-99,999 rowshuge: ≥ 100,000 rows
columnStats()
Collect column statistics.min: Minimum valuemax: Maximum valuenullFraction: Fraction of NULL values (0.0-1.0)nDistinct: Estimated distinct values (PostgreSQL)correlation: Physical vs logical order correlation (PostgreSQL)
columnValues()
Fetch distinct values for low-cardinality columns.report()
Generate business context report.ExecuteFunction
The execute function signature:- Must return an array of rows OR an object with
rowsproperty - For SQL Server: may return object with
recordsetorrecordsets - For MySQL: may return
[rows, fields]tuple
ValidateFunction
The validate function signature:- Return
voidor empty string if valid - Return error message string if invalid
- Throw error if invalid (will be caught and formatted)
- PostgreSQL, SQLite, MySQL:
EXPLAIN {sql} - SQL Server:
SET PARSEONLY ON; {sql}; SET PARSEONLY OFF; - BigQuery: Required (use dry-run)
Error Formatting
Each adapter provides error formatting:Best Practices
1. Choose Appropriate Groundings
2. Use Schema Filtering
3. Handle Connection Pooling
Next Steps
Core API
Text2SQL core classes
Database Adapters
Adapter feature comparison