Skip to main content

Class: SqlDatabase

sql_db.SqlDatabase

Implements

  • SqlDatabaseOptionsParams
  • SqlDatabaseDataSourceParams

Constructors

constructor

Protected new SqlDatabase(fields)

Parameters

NameType
fieldsSqlDatabaseDataSourceParams

Defined in

langchain/src/sql_db.ts:29

Properties

allTables

allTables: SqlTable[] = []

Defined in

langchain/src/sql_db.ts:21


appDataSource

appDataSource: DataSource

Implementation of

SqlDatabaseDataSourceParams.appDataSource

Defined in

langchain/src/sql_db.ts:19


appDataSourceOptions

appDataSourceOptions: DataSourceOptions

Implementation of

SqlDatabaseOptionsParams.appDataSourceOptions

Defined in

langchain/src/sql_db.ts:17


ignoreTables

ignoreTables: string[] = []

Implementation of

SqlDatabaseOptionsParams.ignoreTables

Defined in

langchain/src/sql_db.ts:25


includesTables

includesTables: string[] = []

Implementation of

SqlDatabaseOptionsParams.includesTables

Defined in

langchain/src/sql_db.ts:23


sampleRowsInTableInfo

sampleRowsInTableInfo: number = 3

Implementation of

SqlDatabaseOptionsParams.sampleRowsInTableInfo

Defined in

langchain/src/sql_db.ts:27

Methods

getTableInfo

getTableInfo(targetTables?): Promise<string>

Get information about specified tables.

Follows best practices as specified in: Rajkumar et al, 2022 (https://arxiv.org/abs/2204.00498)

If sample_rows_in_table_info, the specified number of sample rows will be appended to each table description. This can increase performance as demonstrated in the paper.

Parameters

NameType
targetTables?string[]

Returns

Promise<string>

Defined in

langchain/src/sql_db.ts:83


run

run(command, fetch?): Promise<string>

Execute a SQL command and return a string representing the results. If the statement returns rows, a string of the results is returned. If the statement returns no rows, an empty string is returned.

Parameters

NameTypeDefault value
commandstringundefined
fetch"all" | "one""all"

Returns

Promise<string>

Defined in

langchain/src/sql_db.ts:120


serialize

serialize(): SerializedSqlDatabase

Returns

SerializedSqlDatabase

Defined in

langchain/src/sql_db.ts:135


fromDataSourceParams

Static fromDataSourceParams(fields): Promise<SqlDatabase>

Parameters

NameType
fieldsSqlDatabaseDataSourceParams

Returns

Promise<SqlDatabase>

Defined in

langchain/src/sql_db.ts:41


fromOptionsParams

Static fromOptionsParams(fields): Promise<SqlDatabase>

Parameters

NameType
fieldsSqlDatabaseOptionsParams

Returns

Promise<SqlDatabase>

Defined in

langchain/src/sql_db.ts:62


imports

Static imports(): Promise<{ DataSource: typeof DataSource }>

Returns

Promise<{ DataSource: typeof DataSource }>

Defined in

langchain/src/sql_db.ts:145