input: Write a function to create a Python API that fetches data from an SQL database and returns the data in JSON format. The function should handle the database connection and routing using Flask.
  assert index()=="""
  [
      {"id": 1, "name": "John Doe", "email": "john@example.com"},
      {"id": 2, "name": "Jane Doe", "email": "jane@example.com"}
  ]
  """
  assert index()=="""
  []
  """
  assert index()=="""
  [
      {"id": 3, "name": "Alice", "email": "alice@example.com"},
      {"id": 4, "name": "Bob", "email": "bob@example.com"}
  ]
  """
output: 
  from flask import Flask, jsonify
  import sqlite3
  
  app = Flask(__name__)
  
  def index():
      conn = sqlite3.connect('example.db')
      cursor = conn.cursor()
      cursor.execute("SELECT id, name, email FROM users")
      rows = cursor.fetchall()
      conn.close()
      users = [{"id": row[0], "name": row[1], "email": row[2]} for row in rows]
      return jsonify(users)
  