input: Write a function that returns a JSON representation of data fetched from an SQL database named "database.db" containing a table "users". The function should be a route handler for a Flask API, accessible at the root URL. It should connect to the database, execute a SELECT query to get all rows from the "users" table, and return the fetched data in the form of a JSON object.
  assert index()=="""[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]"""
  assert index()=="""[{"id":3,"name":"Charlie"},{"id":4,"name":"David"}]"""
  assert index()=="""[{"id":5,"name":"Eve"}]"""
  assert index()=="" # If no data is returned
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()
      conn.close()
      users = [{"id": row[0], "name": row[1]} for row in rows]
      return jsonify(users)