import sqlite3
import re

conn = sqlite3.connect('smart_learning.db')
cursor = conn.cursor()

cursor.execute("SELECT id, content FROM topics WHERE content LIKE '%**%'")
rows = cursor.fetchall()

for row in rows:
    t_id = row[0]
    content = row[1]
    
    # Replace **text** with <strong>text</strong>
    new_content = re.sub(r'\*\*(.*?)\*\*', r'<strong>\1</strong>', content)
    
    cursor.execute("UPDATE topics SET content = ? WHERE id = ?", (new_content, t_id))

conn.commit()
conn.close()

print(f"Updated {len(rows)} rows.")
