mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-17 02:03:44 +00:00
updated sql_database.py for returning sorted table names. (#6692)
Added code to get the tables info in sorted order in methods get_usable_table_names and get_table_info. Linked to Issue: #6640
This commit is contained in:
parent
9d1b3bab76
commit
3e30a5d967
@ -230,8 +230,8 @@ class SQLDatabase:
|
||||
def get_usable_table_names(self) -> Iterable[str]:
|
||||
"""Get names of tables available."""
|
||||
if self._include_tables:
|
||||
return self._include_tables
|
||||
return self._all_tables - self._ignore_tables
|
||||
return sorted(self._include_tables)
|
||||
return sorted(self._all_tables - self._ignore_tables)
|
||||
|
||||
def get_table_names(self) -> Iterable[str]:
|
||||
"""Get names of tables available."""
|
||||
@ -290,6 +290,7 @@ class SQLDatabase:
|
||||
if has_extra_info:
|
||||
table_info += "*/"
|
||||
tables.append(table_info)
|
||||
tables.sort()
|
||||
final_str = "\n\n".join(tables)
|
||||
return final_str
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user