input: Write a function to develop an API in Python that fetches data from an SQL database and presents the data in the form of a JSON. The function should include the necessary imports and define a Flask app with an endpoint to handle the data fetching.
  
  assert index()==jsonify([{'id': 1, 'name': 'User1'}, {'id': 2, 'name': 'User2'}])
output: 
  from flask import Flask, jsonify
  import sqlite3
  
  app = Flask(__name__)
  
  @app.route('/')
  def index():
      conn = sqlite3.connect('database.db')
      cursor = conn.cursor()
      cursor.execute("SELECT id, name FROM users")
      data = cursor.fetchall()
      conn.close()
      result = [{'id': row[0], 'name': row[1]} for row in data]
      return jsonify(result)
  