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
pull/6727/head
Sumanth Donthula 1 year ago committed by GitHub
parent 9d1b3bab76
commit 3e30a5d967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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…
Cancel
Save