input: Write a function to create a simple API in Python that connects to an SQLite database, fetches data from a 'users' table, and returns it as a JSON.
  from flask import Flask, jsonify
  import sqlite3
  
  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 fetch_users():
      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 fetch_users().get_data(as_text=True) == '[{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]'
  assert fetch_users().get_data(as_text=True) == '[{"id": 3, "name": "Charlie"}, {"id": 4, "name": "David"}]'
  assert fetch_users().get_data(as_text=True) == '[]'
  assert fetch_users().get_data(as_text=True) == '[{"id": 5, "name": "Eve"}]'
  assert fetch_users().get_data(as_text=True) == '[{"id": 6, "name": "Frank"}, {"id": 7, "name": "Grace"}]'
output: 
  def fetch_users():
      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)
  