input: Write a function to convert an SQL query to a Python code snippet that performs the same operation using SQLite. The function should take a string `sql_query` as input, representing the SQL query, and return the corresponding Python code as a string. If the input SQL query is invalid, the function should raise a ValueError.
  
  assert convert_sql_to_python("SELECT * FROM Movies WHERE category = 'horror'") == """import sqlite3
  
  conn = sqlite3.connect('movies.db') 
  cursor = conn.cursor()
  
  cursor.execute("SELECT * FROM Movies WHERE category = 'horror'")
  
  result = cursor.fetchall()
  for row in result:
      print(row)
  
  conn.close()"""
  
  assert convert_sql_to_python("SELECT title, year FROM Movies WHERE category = 'action'") == """import sqlite3
  
  conn = sqlite3.connect('movies.db') 
  cursor = conn.cursor()
  
  cursor.execute("SELECT title, year FROM Movies WHERE category = 'action'")
  
  result = cursor.fetchall()
  for row in result:
      print(row)
  
  conn.close()"""
  
  assert convert_sql_to_python("") == ValueError
  assert convert_sql_to_python("UPDATE Movies SET category = 'drama'") == ValueError
output: def convert_sql_to_python(sql_query):
      if not sql_query or not sql_query.strip().upper().startswith("SELECT"):
          raise ValueError("Invalid SQL query")
      
      return f"""import sqlite3
  
  conn = sqlite3.connect('movies.db') 
  cursor = conn.cursor()
  
  cursor.execute("{sql_query}")
  
  result = cursor.fetchall()
  for row in result:
      print(row)
  
  conn.close()"""