input: Write a function to implement a REST API in Python for creating and reading users. The API should have endpoints for creating a user, reading all users, and reading a single user using Flask and MySQL. If the application runs successfully, return "API is running". If any error occurs while connection to MySQL database, return "Error occurred".
  assert user_api()=="API is running"
output: 
  def user_api():
      try:
          from flask import Flask, request, jsonify
          import mysql.connector
  
          app = Flask(__name__)
  
          def get_db_connection():
              return mysql.connector.connect(
                  host="localhost",
                  user="root",
                  password="password",
                  database="users_db"
              )
  
          @app.route('/users', methods=['POST'])
          def create_user():
              data = request.json
              name = data.get('name')
              email = data.get('email')
  
              conn = get_db_connection()
              cursor = conn.cursor()
              cursor.execute("INSERT INTO users (name, email) VALUES (%s, %s)", (name, email))
              conn.commit()
              cursor.close()
              conn.close()
  
              return jsonify({"message": "User created successfully"}), 201
  
          @app.route('/users', methods=['GET'])
          def get_all_users():
              conn = get_db_connection()
              cursor = conn.cursor(dictionary=True)
              cursor.execute("SELECT * FROM users")
              users = cursor.fetchall()
              cursor.close()
              conn.close()
  
              return jsonify(users), 200
  
          @app.route('/users/<int:user_id>', methods=['GET'])
          def get_user(user_id):
              conn = get_db_connection()
              cursor = conn.cursor(dictionary=True)
              cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
              user = cursor.fetchone()
              cursor.close()
              conn.close()
  
              if user:
                  return jsonify(user), 200
              else:
                  return jsonify({"message": "User not found"}), 404
  
          if __name__ == '__main__':
              app.run(debug=True)
  
          return "API is running"
      except Exception as e:
          return "Error occurred"
  