import sqlite3 from pathlib import Path import sys # Add project root to path project_root = Path(__file__).parent.parent sys.path.append(str(project_root)) from config.settings import Settings def check_collections(): """Check collections in ChromaDB""" chroma_path = Settings.get_chroma_path() sqlite_file = chroma_path / "chroma.sqlite3" print(f"\nExamining: {sqlite_file}") conn = sqlite3.connect(sqlite_file) cursor = conn.cursor() try: # List collections cursor.execute("SELECT name, id FROM collections;") collections = cursor.fetchall() print("\nCollections found:") for name, coll_id in collections: print(f"Name: {name}") print(f"ID: {coll_id}") # Get count of embeddings using correct schema try: cursor.execute(""" SELECT COUNT(*) FROM embeddings e JOIN segments s ON e.segment_id = s.id WHERE s.collection = ? """, (coll_id,)) count = cursor.fetchone()[0] print(f"Embeddings count: {count}") except sqlite3.OperationalError as e: print(f"Could not get count: {e}") # Get metadata using correct schema try: cursor.execute(""" SELECT key, str_value FROM collection_metadata WHERE collection_id = ? """, (coll_id,)) metadata = cursor.fetchall() if metadata: print("Collection Metadata:") for key, value in metadata: print(f" {key}: {value}") except sqlite3.OperationalError as e: print(f"Could not get metadata: {e}") print() finally: conn.close() if __name__ == "__main__": check_collections()