text2sql-ai-agent / utils /sql_utils.py
jaymeen1405's picture
Upload 39 files
58478b5 verified
Raw
History Blame Contribute Delete
373 Bytes
import sqlite3
def list_tables(db_path):
connection = sqlite3.connect(db_path)
cursor = connection.cursor()
cursor.execute("""
SELECT name
FROM sqlite_master
WHERE type='table' AND name NOT LIKE 'sqlite_%'
""")
tables = cursor.fetchall()
connection.close()
return [x[0] for x in tables]