| Name | Type | Description |
|---|---|---|
connection_id* | str | ID of db connection asset |
schema* | str | name of the database schema from which tables will be read |
project_id | str | None | Default: NoneID of project |
space_id | str | None | Default: None |
url | str | None | Default: None |
api_key | str | None | Default: None |
apikey | str | None | Default: None |
token | str | None | Default: None |
password | str | None | Default: None |
username | str | None | Default: None |
instance_id | str | None | Default: None |
version | str | None | Default: None |
verify | str | bool | None | Default: None |
watsonx_client | APIClient | None | Default: None |
ignore_tables | list[str] | None | Default: None |
include_tables | list[str] | None | Default: None |
sample_rows_in_table_info | int | Default: 3 |
max_string_length | int | Default: 300 |
| Name | Type |
|---|---|
| connection_id | str |
| schema | str |
| project_id | str | None |
| space_id | str | None |
| url | str | None |
| api_key | str | None |
| apikey | str | None |
| token | str | None |
| password | str | None |
| username | str | None |
| instance_id | str | None |
| version | str | None |
| verify | str | bool | None |
| watsonx_client | APIClient | None |
| ignore_tables | list[str] | None |
| include_tables | list[str] | None |
| sample_rows_in_table_info | int |
| max_string_length | int |
Watsonx SQL Database class for IBM watsonx.ai databases connection assets.
Uses Arrow Flight to interact with databases via watsonx.
To use, you should have langchain_ibm python package installed,
and the environment variable WATSONX_API_KEY set with your API key, or pass
it as a named parameter api_key to the constructor.
pip install -U langchain-ibm
# or using uv
uv add langchain-ibm
export WATSONX_API_KEY="your-api-key"
apikey and WATSONX_APIKEY are deprecated and will be removed in
version 2.0.0. Use api_key and WATSONX_API_KEY instead.
from langchain_ibm.utilities.sql_database import WatsonxSQLDatabase
wx_sql_database = WatsonxSQLDatabase(
connection_id="<CONNECTION_ID>",
schema="<SCHEMA>",
url="<URL>",
project_id="<PROJECT_ID>",
api_key="<API_KEY>",
)ValueError - if some required credentials are missingRuntimeError - if no tables found in given schemaID of space
URL to the Watson Machine Learning or CPD instance
API key to the Watson Machine Learning or CPD instance
API key to the Watson Machine Learning or CPD instance (deprecated)
service token, used in token authentication
password to the CPD instance
username to the CPD instance
instance_id of the CPD instance
version of the CPD instance
certificate verification flag
instance of ibm_watsonx_ai.APIClient
list of tables that will be ignored
list of tables that should be included
number of first rows to be added to the table info
max length of string