input: Write a function to create a Flask API that fetches data from an SQL database and returns the data in JSON format. The function should initialize a Flask app, define a route to fetch and return all users from the 'users' table in the database, and run the app in debug mode.
  assert index() == jsonify([{'id': 1, 'name': 'John'}, {'id': 2, 'name': 'Doe'}])
  assert index() == jsonify([])
  assert index() == jsonify([{'id': 3, 'name': 'Alice'}, {'id': 4, 'name': 'Bob'}])
output: 
  from flask import Flask, jsonify
  import sqlite3
  
  app = Flask(__name__)
  
  def index():
      conn = sqlite3.connect('database.db')
      cursor = conn.cursor()
      cursor.execute("SELECT id, name FROM users")
      users = cursor.fetchall()
      conn.close()
      return jsonify([{'id': user[0], 'name': user[1]} for user in users])
  
  app.add_url_rule('/', 'index', index)
  
  if __name__ == '__main__':
      app.run(debug=True)
  