input: Write a function to create a Flask API that fetches data from an SQLite database and returns the data in JSON format. The function should establish a connection to the database, retrieve all records from the 'users' table, and return them as a JSON response.
  assert index() == b'[{"id":1,"name":"Alice"}]'
  assert index() == b'[{"id":1,"name":"Bob"}]'
  assert index() == b'[{"id":2,"name":"Charlie"}]'
  assert index() == b'[{"id":3,"name":"David"}]'
  assert index() == b'[]'
output: 
  def index():
      import sqlite3
      from flask import jsonify
      conn = sqlite3.connect('database.db')
      cursor = conn.cursor()
      cursor.execute("SELECT * FROM users")
      rows = cursor.fetchall()
      users = [{'id': row[0], 'name': row[1]} for row in rows]
      conn.close()
      return jsonify(users)
  