input: Write a function to create an API in Python that fetches data from an SQL database and presents the data in the form of a JSON. If the database is empty, return an empty JSON object. The function should include a Flask endpoint that, when accessed, returns the data from the 'users' table in JSON format.
  
  assert api_fetch_data()==jsonify([{'id': 1, 'name': 'Alice', 'age': 30}, {'id': 2, 'name': 'Bob', 'age': 25}])
  assert api_fetch_data()==jsonify([])
output: 
  def api_fetch_data():
      from flask import Flask, jsonify
      import sqlite3
  
      app = Flask(__name__)
  
      @app.route('/fetch_data', methods=['GET'])
      def fetch_data():
          conn = sqlite3.connect('database.db')
          cursor = conn.cursor()
          cursor.execute("SELECT * FROM users")
          rows = cursor.fetchall()
          conn.close()
  
          if not rows:
              return jsonify([])
  
          data = []
          for row in rows:
              data.append({'id': row[0], 'name': row[1], 'age': row[2]})
  
          return jsonify(data)
  
      with app.app_context():
          return fetch_data()
  