Class SQLDatabase

java.lang.Object
com.hw.langchain.sql.database.SQLDatabase

public class SQLDatabase extends Object
SQLAlchemy wrapper around a database.
Author:
HamaWhite
  • Constructor Details

  • Method Details

    • fromUri

      public static SQLDatabase fromUri(String url, String username, String password)
    • getDialect

      public String getDialect()
      Dialect will convert to lowercase
    • getUsableTableNames

      public List<String> getUsableTableNames()
      Get names of tables available.
    • getTableInfo

      public String getTableInfo(List<String> tableNames)
      Get information about specified tables.

      Follows best practices as specified in: Rajkumar et al, 2022

      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.

    • getTableDdl

      public String getTableDdl(String tableName)
    • getTableIndexes

      public String getTableIndexes(String tableName)
    • getSampleRows

      public String getSampleRows(String tableName)
    • run

      public String run(String command, boolean includeColumnName)
      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.

    • close

      public void close()