File size: 2,019 Bytes
d147321 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 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() |