input: Write a function to create a Flask API that connects to an SQL database and returns the data in JSON format. The function should take no input and should be able to fetch all rows from a table named "users" and return them as a JSON response.
  import json 
  import sqlite3
  from flask import Flask, request, jsonify 
  
  app = Flask(__name__) 
    
  def dict_factory(cursor, row):
      d = {}
      for idx, col in enumerate(cursor.description):
          d[col[0]] = row[idx]
      return d 
    
  @app.route('/', methods=['GET'])
  def index(): 
      connection = sqlite3.connect('database.db')
      connection.row_factory = dict_factory
      cur = connection.cursor() 
      all_users = cur.execute('SELECT * FROM users;').fetchall() 
      return jsonify(all_users) 
    
  if __name__ == '__main__': 
      app.run(debug = True)
  
  assert index() == jsonify([{'id': 1, 'name': 'Alice'}, {'id': 2, 'name': 'Bob'}])
  assert index() == jsonify([{'id': 2, 'name': 'Bob'}, {'id': 3, 'name': 'Charlie'}])
  assert index() == jsonify([{'id': 3, 'name': 'Charlie'}, {'id': 4, 'name': 'Dave'}])
  assert index() == jsonify([])
  assert index() == jsonify([{'id': 1, 'name': 'Alice'}, {'id': 2, 'name': 'Bob'}, {'id': 3, 'name': 'Charlie'}])
output: 
  def index(): 
      connection = sqlite3.connect('database.db')
      connection.row_factory = dict_factory
      cur = connection.cursor() 
      all_users = cur.execute('SELECT * FROM users;').fetchall() 
      return jsonify(all_users)
  