input: 
  from flask import Flask, jsonify, request
  from flask_mysqldb import MySQL
  
  def user_api(name, email, id):
      """ Implement a REST API for creating and reading users. The API should have endpoints 
      for creating a user, reading all users, and reading a single user.
      >>> user_api('John', 'john@example.com', 1)
      {'message': 'User created'}
      >>> user_api('', '', None)
      [{'id': 1, 'name': 'John', 'email': 'john@example.com'}]
      >>> user_api('', '', 1)
      {'id': 1, 'name': 'John', 'email': 'john@example.com'}
      """
      
      app = Flask(__name__)
  
      # Mysql configuration
      app.config['MYSQL_USER'] = 'root'
      app.config['MYSQL_PASSWORD'] = 'password'
      app.config['MYSQL_DB'] = 'users'
      app.config['MYSQL_CURSORCLASS'] = 'DictCursor'
  
      mysql = MySQL(app)
  
      @app.route('/users', methods=['POST'])
      def create_user():
          name = request.json['name']
          email = request.json['email']
  
          cur = mysql.connection.cursor()
          cur.execute("INSERT INTO users (name, email) VALUES (%s, %s)", (name, email))
          mysql.connection.commit()
          cur.close()
  
          return jsonify({'message': 'User created'})
  
      @app.route('/users', methods=['GET'])
      def get_users():
          cur = mysql.connection.cursor()
          cur.execute("SELECT * FROM users")
          users = cur.fetchall()
          cur.close()
  
          return jsonify(users)
  
      @app.route('/users/<int:id>', methods=['GET'])
      def get_user(id):
          cur = mysql.connection.cursor()
          cur.execute("SELECT * FROM users WHERE id=%s", (id,))
          user = cur.fetchone()
          cur.close()
  
          return jsonify(user)
  
      return app(debug=True)
  
output:     
      if name and email and id is None:
          with app.app_context():
              with mysql.connection.cursor() as cur:
                  cur.execute("INSERT INTO users (name, email) VALUES (%s, %s)", (name, email))
                  mysql.connection.commit()
          return {'message': 'User created'}
      elif not name and not email and id is None:
          with app.app_context():
              with mysql.connection.cursor() as cur:
                  cur.execute("SELECT * FROM users")
                  users = cur.fetchall()
          return users
      elif not name and not email and id is not None:
          with app.app_context():
              with mysql.connection.cursor() as cur:
                  cur.execute("SELECT * FROM users WHERE id=%s", (id,))
                  user = cur.fetchone()
          return user
  