Skip to content

Commit 3ab3e2d

Browse files
committed
moved get_available_tables to cmd history
1 parent 2ae905e commit 3ab3e2d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

npcpy/memory/command_history.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,3 +870,28 @@ def save_attachment_to_message(
870870
except Exception as e:
871871
print(f"Error saving attachment: {str(e)}")
872872
return False
873+
874+
def get_available_tables(db_path: str) -> str:
875+
"""
876+
Function Description:
877+
This function gets the available tables in the database.
878+
Args:
879+
db_path (str): The database path.
880+
Keyword Args:
881+
None
882+
Returns:
883+
str: The available tables in the database.
884+
"""
885+
886+
try:
887+
with sqlite3.connect(db_path) as conn:
888+
cursor = conn.cursor()
889+
cursor.execute(
890+
"SELECT name FROM sqlite_master WHERE type='table' AND name != 'command_history'"
891+
)
892+
tables = cursor.fetchall()
893+
894+
return tables
895+
except Exception as e:
896+
print(f"Error getting available tables: {e}")
897+
return ""

0 commit comments

Comments
 (0)