Database
The Database module provides functions to manage database connections and access schema and table information.
Modify Database Connections
This function allows you to modify existing database connections or add new ones.
async function modifyConnections(
params: ModifyDBConnectionRequest,
signal?: AbortSignal)
: Promise<ModifyDBConnectionResponse>;
Parameters:
-
params
(required): An object containing the modify database connection request parameters.updated
(optional): An array ofDBConnection
objects representing the updated database connections.removed
(optional): An array of strings representing the keys of the database connections to be removed.validate_before_save
(optional): A boolean value indicating whether to validate the changes before saving.user_id
(optional): The ID of the user performing the modification.
-
signal
(optional): An AbortSignal object for aborting the request.
Returns:
A Promise resolving to a ModifyDBConnectionResponse
object containing the updated connectors and diagnostics.
The ModifyDBConnectionResponse
object represents the response of the "modify database connection" operation and contains the following fields:
-
connectors
(optional): An array ofDBConnection
objects representing the updated database connectors as a result of the operation. EachDBConnection
object may contain the following fields:key
(required): A string representing the unique key or identifier of the database connection.db_type
(required): A string representing the type of the database (e.g., MySQL, PostgreSQL).description
(optional): A string representing a description or additional information about the database connection.account_name
(optional): A string representing the account name associated with the database connection.username
(optional): A string representing the username used to connect to the database.password
(optional): A string representing the password used to authenticate the database connection.database
(optional): A string representing the name of the specific database to connect to.warehouse
(optional): A string representing the warehouse for the database connection.role
(optional): A string representing the role associated with the database connection.path
(optional): A string representing the path to the database.parameters
(optional): An object containing additional parameters related to the database connection.sample_col_values
(optional): A boolean value denoting if you want Waii to sample string/variant columns. Allowing Waii to sample can help it to generate better queries.db_content_filters
(optional): If you want Waii to exclude certain columns , tables from database while generating the query, you can pass the db_content_filter.push
: This is set to true if you are adding push based connectionalways_include_tables
(optional): If it is not None, then these tables will always be included, even if table selector doesn't select them.embedding_model
(optional): A string value denoting embedding model used for similarity search within the knowledge graph.
-
connector_status
(optional): An array ofConnectorStatus
objects representing the status of the database connectors. EachConnectorStatus
object may contain the following fields:status
(required): A string representing the status of the database connection. Valid values are "completed", "indexing", "not-started".schema_status
(optional): An array ofSchemaIndexingStatus
objects representing the status of the schema indexing. EachSchemaIndexingStatus
object may contain the following fields:status
(required): A string representing the status of the schema indexing. Valid values are "completed", "indexing", "not-started".n_pending_indexing_tables
(required): A number representing the number of tables pending indexing.n_total_tables
(required): A number representing the total number of tables.
Get Database Connections
This function allows you to retrieve the list of current database connections.
async function getConnections(
params: GetDBConnectionRequest = {},
signal?: AbortSignal)
: Promise<GetDBConnectionResponse>;
Parameters:
-
params
(optional): An object containing the get database connection request parameters. -
signal
(optional): An AbortSignal object for aborting the request.
Returns:
A Promise resolving to a GetDBConnectionResponse
object containing the list of database connections and diagnostics.
The GetDBConnectionResponse
object represents the response of the "get database connections" operation and contains the following fields:
-
connectors
(optional): An array ofDBConnection
objects representing the list of database connectors retrieved from the server. EachDBConnection
object may contain the following fields:key
(required): A string representing the unique key or identifier of the database connection.db_type
(required): A string representing the type of the database (e.g., MySQL, PostgreSQL).description
(optional): A string representing a description or additional information about the database connection.account_name
(optional): A string representing the account name associated with the database connection.username
(optional): A string representing the username used to connect to the database.password
(optional): A string representing the password used to authenticate the database connection.database
(optional): A string representing the name of the specific database to connect to.warehouse
(optional): A string representing the warehouse for the database connection.role
(optional): A string representing the role associated with the database connection.path
(optional): A string representing the path to the database.parameters
(optional): An object containing additional parameters related to the database connection.
Get Default Connection
This function allows you to get default database connection for subsequent API calls.
function getDefaultConnection(): void;
Activate Connection
This function allows you to activate a specific database connection for subsequent API calls.
function activateConnection(key: string): void;
Parameters:
key
(required): The key of the database connection to activate.
Get Catalogs
This function allows you to fetch information about catalogs, schemas, and tables.
async function getCatalogs(
params: GetCatalogRequest = {},
signal?: AbortSignal)
: Promise<GetCatalogResponse>;
Parameters:
-
params
(optional): An object containing the get catalogs request parameters.ask
(optional):You can do semantic search by providing a question here. For example, "How many cars sold in 2021?". Waii will try to filter the tables/cols based on the question.search_context
(optional): SearchContext[] . You can provide a list of search contexts to filter the tables/cols. For example, you can provide a list of table names, column names, etc. Waii will try to filter the tables/cols based on the search contexts.
-
signal
(optional): An AbortSignal object for aborting the request.
Returns:
A Promise resolving to a GetCatalogResponse
object containing the list of catalogs and associated schema and table information.
The GetCatalogResponse
object represents the response of the "get catalogs" operation and contains the following fields:
catalogs
(optional): An array ofCatalog
objects representing the list of catalogs retrieved from the server. EachCatalog
object may contain the following fields:-
name
(required): A string representing the name of the catalog. -
schemas
(optional): An array ofSchema
objects representing the list of schemas associated with the catalog. EachSchema
object may contain the following fields:name
(required): ASchemaName
object representing the name of the schema.tables
(optional): An array ofTable
objects representing the list of tables in the schema. EachTable
object may contain the following fields:name
(required): ATableName
object representing the name of the table.columns
(optional): An array ofColumn
objects representing the list of columns in the table. EachColumn
object may contain the following fields:name
(required): A string representing the name of the column.type
(required): A string representing the data type of the column.comment
(optional): A string representing any comment or description associated with the column.sample_values
(optional): An array ofColumnSampleValues
objects representing sample values for the column. EachColumnSampleValues
object may contain the following fields:values
(optional): An array of objects representing sample values for the column, along with their respective counts. Each object may havevalue
(string) andcount
(number) properties.
refs
(optional): An array ofTableReference
objects representing the references to other tables. EachTableReference
object may contain the following fields:src_table
(optional): An array ofTableName
objects representing the source tables.src_cols
(optional): An array of strings representing the source columns.ref_table
(optional): An array ofTableName
objects representing the referenced tables.ref_cols
(optional): An array of strings representing the referenced columns.
-
description
(optional): ASchemaDescription
object representing the description of the schema.
-
Returns:
A promise resolving to a UpdateTableDescriptionResponse
object containing the updated table description.
Update Schema Description
This function allows you to update the description of a schema.
async function updateSchemaDescription(
params: UpdateSchemaDescriptionRequest,
signal?: AbortSignal)
: Promise<UpdateSchemaDescriptionResponse>;
Parameters:
-
params
(required): An object containing the modify table request parameters.schema_name
(required): ASchemaName
object representing the name of the schema. EachSchemaName
object may contain the following fields:schema_name
(required): The name of the schema (if applicable).database_name
(optional): The name of the database (if applicable).
description
(optional): An objectSchemaDescription
representing the description of the schema. EachSchemaDescription
object may contain the following fields:- summary (optional): A string representing a summary of the schema's purpose or objective.
- detailed_steps (optional): An array of strings providing detailed steps or actions performed by the schema.
- common_tables (optional): An array of
TableDescriptionPair
objects representing the common tables in the schema. EachTableDescriptionPair
object may contain the following fields:name
(required): A string representing the name of the table.description
(optional): A string representing the description of the table.
-
signal
(optional): An AbortSignal object for aborting the request.
Returns:
A promise resolving to a UpdateSchemaDescriptionResponse
object containing the updated schema description.
Update Table Description
This function allows you to update the description of a table.
async function updateTableDescription(
params: UpdateTableDescriptionRequest,
signal?: AbortSignal)
: Promise<UpdateTableDescriptionResponse>;
Parameters:
-
params
(required): An object containing the modify table request parameters.table_name
(required): ATableName
object representing the name of the table. EachTableName
object may contain the following fields:table_name
(required): The name of the table.schema_name
(optional): The name of the schema (if applicable).database_name
(optional): The name of the database (if applicable).
description
(optional): A string representing the description of the table.
-
signal
(optional): An AbortSignal object for aborting the request.
Update Constraints
This function allows you to update table constraints (primary/foreign keys).
async function updateConstraint(
params: UpdateConstraintRequest,
signal?: AbortSignal)
: Promise<UpdateConstraintResponse>;
Parameters:
-
params
(required): An object containing the constraint update request parameters.updated_constraints
(required): Array ofTableConstraints
objects representing constraints to update. Each contains:table_name
:TableName
object identifying the tableconstraints
: Array ofConstraint
objects with:source
: Origin of constraint (manual, database, inferred, etc)constraint_type
: primary/foreign key typecols
: Columns involved in constraintrelationship_type
: For foreign keys (one-to-one, one-to-many, etc)src_table
/src_cols
: For foreign key references
constraint_type
: Type of constraint being modifiedconstraint_source
: Source of the constraints
-
signal
(optional): AbortSignal for request cancellation
Returns:
A Promise resolving to an UpdateConstraintResponse
containing:
updated_tables
: Array ofTableName
objects for tables that received constraint updates