input: Write a function to create a Flask API that fetches data from an SQL database and presents the data in the form of JSON. The function should connect to the database using 'sqlite3', fetch all user data from the 'users' table, and return it as JSON. If the database fetch is successful, it should return the JSON data; otherwise, it should handle the exceptions accordingly.
  assert create_api() is None
  assert create_api() is None
  assert create_api() is None
  assert create_api() is None
  assert create_api() is None
output: 
  def create_api():
      from flask import Flask, jsonify
      import sqlite3
  
      app = Flask(__name__)
  
      @app.route('/users', methods=['GET'])
      def get_users():
          try:
              conn = sqlite3.connect('database.db')
              cursor = conn.cursor()
              cursor.execute("SELECT * FROM users")
              rows = cursor.fetchall()
              users = [{'id': row[0], 'name': row[1], 'email': row[2]} for row in rows]
              return jsonify(users)
          except Exception as e:
              return jsonify({'error': str(e)}), 500
          finally:
              conn.close()
  
      if __name__ == '__main__':
          app.run(debug=True)
  