input: Write a function that creates an API in Python to fetch data from an SQL database and return the data in JSON format. The function should use the Flask framework and sqlite3 for database interactions.
  
  
  import json 
  import sqlite3
  from flask import Flask, request, jsonify 
  
  app = Flask(__name__) 
    
  def create_api():
      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 create_api() is not None # Check if the API creation function runs successfully
  assert type(create_api()) == type(app) # Check if the returned object is a Flask instance
output: def create_api():
      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)