#!/usr/bin/env python3 """ Debug vecs library collection naming """ import vecs import traceback def debug_vecs_naming(): """Debug the vecs collection naming issue""" print("=" * 60) print("VECS COLLECTION NAMING DEBUG") print("=" * 60) connection_string = "postgresql://supabase_admin:CzkaYmRvc26Y@localhost:5435/postgres" try: print("๐Ÿ”Œ Connecting to database...") db = vecs.create_client(connection_string) print("โœ… Connected successfully") print("\n๐Ÿ“‹ Listing existing collections...") collections = db.list_collections() print(f"Existing collections: {collections}") # Test different collection names test_names = [ "mem0_vectors", "mem0_working_test", "simple_test", "test123", "debugtest" ] for name in test_names: print(f"\n๐Ÿงช Testing collection name: '{name}'") try: # Try to get or create collection collection = db.get_or_create_collection(name=name, dimension=128) print(f" โœ… Created/Retrieved: {collection.name}") # Check actual table name in database print(f" ๐Ÿ“Š Collection info: {collection.describe()}") # Clean up test collection db.delete_collection(name) print(f" ๐Ÿ—‘๏ธ Cleaned up collection: {name}") except Exception as e: print(f" โŒ Failed: {str(e)}") print(f" Error type: {type(e).__name__}") if "DuplicateTable" in str(e): print(f" ๐Ÿ” Table already exists, examining error...") # Extract the actual table name from error error_str = str(e) if 'relation "' in error_str: start = error_str.find('relation "') + len('relation "') end = error_str.find('" already exists', start) if end > start: actual_table = error_str[start:end] print(f" ๐Ÿ“‹ Actual table name attempted: {actual_table}") print("\n๐Ÿ” Checking database schema for existing tables...") # Connect directly to check tables import psycopg2 conn = psycopg2.connect("postgresql://supabase_admin:CzkaYmRvc26Y@localhost:5435/postgres") cur = conn.cursor() cur.execute("SELECT table_name FROM information_schema.tables WHERE table_schema = 'vecs';") tables = cur.fetchall() print(f"Tables in 'vecs' schema: {[t[0] for t in tables]}") cur.close() conn.close() except Exception as e: print(f"โŒ Debug failed: {str(e)}") traceback.print_exc() if __name__ == "__main__": debug_vecs_naming()