mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-18 10:43:36 +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]:
|
def get_usable_table_names(self) -> Iterable[str]:
|
||||||
"""Get names of tables available."""
|
"""Get names of tables available."""
|
||||||
if self._include_tables:
|
if self._include_tables:
|
||||||
return self._include_tables
|
return sorted(self._include_tables)
|
||||||
return self._all_tables - self._ignore_tables
|
return sorted(self._all_tables - self._ignore_tables)
|
||||||
|
|
||||||
def get_table_names(self) -> Iterable[str]:
|
def get_table_names(self) -> Iterable[str]:
|
||||||
"""Get names of tables available."""
|
"""Get names of tables available."""
|
||||||
@ -290,6 +290,7 @@ class SQLDatabase:
|
|||||||
if has_extra_info:
|
if has_extra_info:
|
||||||
table_info += "*/"
|
table_info += "*/"
|
||||||
tables.append(table_info)
|
tables.append(table_info)
|
||||||
|
tables.sort()
|
||||||
final_str = "\n\n".join(tables)
|
final_str = "\n\n".join(tables)
|
||||||
return final_str
|
return final_str
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user