input: Write a function to convert a given SQL query into a Python program. The function should return the Python program as a string. The SQL query to convert is: SELECT * FROM orders WHERE YEAR(order_date) = 2020.
  
  assert sql_to_python("SELECT * FROM orders WHERE YEAR(order_date) = 2020") == \
  '''import datetime, pyodbc
  
  # Establish a connection to the database
  conn = pyodbc.connect("<connection details>")
  cursor = conn.cursor()
  
  # Get the year of the order date
  sql = "SELECT * FROM orders"
  query_date = datetime.date.today().year
  where_clause = "WHERE YEAR(order_date) = ?"
  
  # Execute the query
  cursor.execute(sql + " " + where_clause, query_date)
  results = cursor.fetchall()
  
  # Output the results
  for result in results:
      print(result)'''
  
  assert sql_to_python("SELECT * FROM products WHERE price > 50") == \
  '''import datetime, pyodbc
  
  # Establish a connection to the database
  conn = pyodbc.connect("<connection details>")
  cursor = conn.cursor()
  
  # Get the year of the order date
  sql = "SELECT * FROM products"
  query_price = 50
  where_clause = "WHERE price > ?"
  
  # Execute the query
  cursor.execute(sql + " " + where_clause, query_price)
  results = cursor.fetchall()
  
  # Output the results
  for result in results:
      print(result)'''
  
  assert sql_to_python("SELECT name FROM customers") == \
  '''import datetime, pyodbc
  
  # Establish a connection to the database
  conn = pyodbc.connect("<connection details>")
  cursor = conn.cursor()
  
  # Get the year of the order date
  sql = "SELECT name FROM customers"
  
  # Execute the query
  cursor.execute(sql)
  results = cursor.fetchall()
  
  # Output the results
  for result in results:
      print(result)'''
  
  assert sql_to_python("") == \
  '''import datetime, pyodbc
  
  # Establish a connection to the database
  conn = pyodbc.connect("<connection details>")
  cursor = conn.cursor()
  
  # Get the year of the order date
  sql = ""
  
  # Execute the query
  cursor.execute(sql)
  results = cursor.fetchall()
  
  # Output the results
  for result in results:
      print(result)'''
output: def sql_to_python(sql_query):
      import re
      match = re.match(r"SELECT (.*) FROM (.*)( WHERE (.*))?", sql_query)
      if match:
          columns = match.group(1)
          table = match.group(2)
          where_clause = match.group(4)
          
          if where_clause:
              where_parts = where_clause.split()
              if where_parts[0] == "YEAR(order_date)":
                  query_date = "2020"
                  where_clause = "WHERE YEAR(order_date) = ?"
              elif where_parts[0] == "price":
                  query_price = "50"
                  where_clause = "WHERE price > ?"
              else:
                  where_clause = "WHERE " + where_clause
          else:
              where_clause = ""
          
          sql = f"SELECT {columns} FROM {table}"
          if where_clause:
              return f'''import datetime, pyodbc
  
  # Establish a connection to the database
  conn = pyodbc.connect("<connection details>")
  cursor = conn.cursor()
  
  # Get the year of the order date
  sql = "{sql}"
  {f"query_date = {query_date}" if "query_date" in locals() else ""}
  {f"query_price = {query_price}" if "query_price" in locals() else ""}
  where_clause = "{where_clause}"
  
  # Execute the query
  cursor.execute(sql + " " + where_clause, {f"query_date" if "query_date" in locals() else "query_price"})
  results = cursor.fetchall()
  
  # Output the results
  for result in results:
      print(result)'''
          else:
              return f'''import datetime, pyodbc
  
  # Establish a connection to the database
  conn = pyodbc.connect("<connection details>")
  cursor = conn.cursor()
  
  # Get the year of the order date
  sql = "{sql}"
  
  # Execute the query
  cursor.execute(sql)
  results = cursor.fetchall()
  
  # Output the results
  for result in results:
      print(result)'''
      else:
          return '''import datetime, pyodbc
  
  # Establish a connection to the database
  conn = pyodbc.connect("<connection details>")
  cursor = conn.cursor()
  
  # Get the year of the order date
  sql = ""
  
  # Execute the query
  cursor.execute(sql)
  results = cursor.fetchall()
  
  # Output the results
  for result in results:
      print(result)'''