"""
ChromaDB SQLite Fix - Use pysqlite3 instead of built-in sqlite3

This module replaces the system sqlite3 with pysqlite3-binary to meet
ChromaDB's SQLite 3.35.0+ requirement.

Auto-generated by MIRA setup to ensure ChromaDB compatibility.
"""

import sys

def apply_sqlite_fix():
    """Replace sqlite3 with pysqlite3 to meet ChromaDB requirements."""
    try:
        # Import pysqlite3
        import pysqlite3
        
        # Replace sqlite3 with pysqlite3 in sys.modules
        sys.modules['sqlite3'] = pysqlite3
        sys.modules['sqlite3.dbapi2'] = pysqlite3.dbapi2
        
        # Verify the version
        import sqlite3
        version = sqlite3.sqlite_version
        print(f"✅ SQLite upgraded to version {version} using pysqlite3-binary")
        
        return True
        
    except ImportError:
        print("❌ pysqlite3-binary not installed. Run: pip install pysqlite3-binary")
        return False


# Apply the fix immediately when imported
if __name__ != "__main__":
    apply_sqlite_fix()
