48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
import os
|
|
from pathlib import Path
|
|
import sqlite3
|
|
|
|
def explore_qmd():
|
|
foxy_home_str = os.environ.get("FOXY_HOME", "/home/foxy/.openclaw")
|
|
# If running on windows local, this might resolve weirdly.
|
|
# We will try the raw string first.
|
|
home = Path(foxy_home_str)
|
|
|
|
# Alternatively try C:\home\foxy\.openclaw if windows
|
|
if not home.exists() and os.name == 'nt':
|
|
alt_home = Path("C:") / foxy_home_str
|
|
if alt_home.exists():
|
|
home = alt_home
|
|
|
|
workspace = home / "workspace"
|
|
print("Exploring workspace:", workspace)
|
|
print("Exists:", workspace.exists())
|
|
|
|
if not workspace.exists():
|
|
print("Cannot find workspace.")
|
|
return
|
|
|
|
sqlite_files = list(workspace.rglob("*.sqlite")) + list(workspace.rglob("*.db")) + list(workspace.rglob("*.qmd"))
|
|
print("Found sqlite files:", len(sqlite_files))
|
|
|
|
for f in sqlite_files:
|
|
print("\n--- SCHEMA FOR", f)
|
|
try:
|
|
conn = sqlite3.connect(f)
|
|
cursor = conn.cursor()
|
|
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
|
tables = cursor.fetchall()
|
|
for t in tables:
|
|
table_name = t[0]
|
|
print(f"Table: {table_name}")
|
|
cursor.execute(f"PRAGMA table_info('{table_name}')")
|
|
columns = cursor.fetchall()
|
|
for c in columns:
|
|
print(f" - {c[1]} ({c[2]})")
|
|
conn.close()
|
|
except Exception as e:
|
|
print("Error reading db:", e)
|
|
|
|
if __name__ == "__main__":
|
|
explore_qmd()
|