mrs_plugin/general.py
def status(**kwargs):
    """Checks the MRS service status and prints its

    Args:
        **kwargs: Additional options

    Keyword Args:
        session (object): The database session to use
        interactive (bool): Indicates whether to execute in interactive mode
        raise_exceptions (bool): If set to true exceptions are raised
        return_formatted (bool): If set to true, a list object is returned

    Returns:
        None
    """

    session = kwargs.get("session")
    interactive = kwargs.get("interactive", core.get_interactive_default())
    raise_exceptions = kwargs.get("raise_exceptions", not interactive)
    return_formatted = kwargs.get("return_formatted", interactive)

    try:
        session = core.get_current_session(session)

        if interactive:
            print("Checking the current status of the MRS...\n")

        # Check if the MRS metadata schema already exists
        res = session.run_sql("""
            SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
            WHERE SCHEMA_NAME = 'mysql_rest_service_metadata'
            """)
        row = res.fetch_one()
        if not row:
            if return_formatted:
                print("The MySQL REST Data Service is not configured yet. "
                      "Run mrs.configure() to configure the service.")
            else:
                return {
                    'service_configured': False,
                    'service_enabled': False,
                    'service_count': 0}
        else:
            result = {'service_configured': True}

        # Make sure the MRS metadata schema exists and has the right version
        core.ensure_rds_metadata_schema(session=session)

        # Check if MRS is enabled
        res = session.run_sql("""
            SELECT service_enabled FROM `mysql_rest_service_metadata`.config
            WHERE id = 1
            """)
        row = res.fetch_one()
        result['service_enabled'] = row.get_field("service_enabled")

        # Get the number of enabled services
        res = session.run_sql("""
            SELECT SUM(enabled) as service_count
            FROM `mysql_rest_service_metadata`.service
            """)
        row = res.fetch_one()
        result['service_count'] = int(row.get_field("service_count")) \
            if row and row.get_field("service_count") else 0

        if return_formatted:
            if result['service_enabled']:
                print(f"The MySQL REST Data Service is enabled.")
                print("Number of enabled MRS services: "
                      f"{result['service_count']}")
                if int(result['service_count']) == 0:
                    print("\nUse mrs.add.service() to add a new service.")
            else:
                print(f"The MySQL REST Data Service is disabled.")
        else:
            return result
    except Exception as e:
        if raise_exceptions:
            raise
        else:
            print(f"Error: {str(e)}")
Checks the MRS service status and prints its

    Args:
        **kwargs: Additional options

    Keyword Args:
        session (object): The database session to use
        interactive (bool): Indicates whether to execute in interactive mode
        raise_exceptions (bool): If set to true exceptions are raised
        return_formatted (bool): If set to true, a list object is returned

    Returns:
        None
    
Checks the MRS service status and prints its
Checks the MRS service status and prints its
def status(**kwargs):
    session = kwargs.get("session")
    interactive = kwargs.get("interactive", core.get_interactive_default())
    raise_exceptions = kwargs.get("raise_exceptions", not interactive)
    return_formatted = kwargs.get("return_formatted", interactive)
    try:
        session = core.get_current_session(session)
        if interactive:
            print("Checking the current status of the MRS...\n")
        res = session.run_sql("""
            SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
            WHERE SCHEMA_NAME = 'mysql_rest_service_metadata'
            """)
        row = res.fetch_one()
        if not row:
            if return_formatted:
                print("The MySQL REST Data Service is not configured yet. "
                      "Run mrs.configure() to configure the service.")
            else:
                return {
                    'service_configured': False,
                    'service_enabled': False,
                    'service_count': 0}
        else:
            result = {'service_configured': True}
        core.ensure_rds_metadata_schema(session=session)
        res = session.run_sql("""
            SELECT service_enabled FROM `mysql_rest_service_metadata`.config
            WHERE id = 1
            """)
        row = res.fetch_one()
        result['service_enabled'] = row.get_field("service_enabled")
        res = session.run_sql("""
            SELECT SUM(enabled) as service_count
            FROM `mysql_rest_service_metadata`.service
            """)
        row = res.fetch_one()
        result['service_count'] = int(row.get_field("service_count")) \
            if row and row.get_field("service_count") else 0
        if return_formatted:
            if result['service_enabled']:
                print(f"The MySQL REST Data Service is enabled.")
                print("Number of enabled MRS services: "
                      f"{result['service_count']}")
                if int(result['service_count']) == 0:
                    print("\nUse mrs.add.service() to add a new service.")
            else:
                print(f"The MySQL REST Data Service is disabled.")
        else:
            return result
    except Exception as e:
        if raise_exceptions:
            raise
        else:
            print(f"Error: {str(e)}")
def status ( ** kwargs ) : session = kwargs . get ( "session" ) interactive = kwargs . get ( "interactive" , core . get_interactive_default ( ) ) raise_exceptions = kwargs . get ( "raise_exceptions" , not interactive ) return_formatted = kwargs . get ( "return_formatted" , interactive ) try : session = core . get_current_session ( session ) if interactive : print ( "Checking the current status of the MRS...\n" ) res = session . run_sql ( """
            SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
            WHERE SCHEMA_NAME = 'mysql_rest_service_metadata'
            """ ) row = res . fetch_one ( ) if not row : if return_formatted : print ( "The MySQL REST Data Service is not configured yet. " "Run mrs.configure() to configure the service." ) else : return { 'service_configured' : False , 'service_enabled' : False , 'service_count' : 0 } else : result = { 'service_configured' : True } core . ensure_rds_metadata_schema ( session = session ) res = session . run_sql ( """
            SELECT service_enabled FROM `mysql_rest_service_metadata`.config
            WHERE id = 1
            """ ) row = res . fetch_one ( ) result [ 'service_enabled' ] = row . get_field ( "service_enabled" ) res = session . run_sql ( """
            SELECT SUM(enabled) as service_count
            FROM `mysql_rest_service_metadata`.service
            """ ) row = res . fetch_one ( ) result [ 'service_count' ] = int ( row . get_field ( "service_count" ) ) if row and row . get_field ( "service_count" ) else 0 if return_formatted : if result [ 'service_enabled' ] : print ( f"The MySQL REST Data Service is enabled." ) print ( "Number of enabled MRS services: " f"{result['service_count']}" ) if int ( result [ 'service_count' ] ) == 0 : print ( "\nUse mrs.add.service() to add a new service." ) else : print ( f"The MySQL REST Data Service is disabled." ) else : return result except Exception as e : if raise_exceptions : raise else : print ( f"Error: {str(e)}" )
Checks the MRS service status and prints its
Checks the MRS service status and prints its
"""Checks the MRS service status and prints its

    Args:
        **kwargs: Additional options

    Keyword Args:
        session (object): The database session to use
        interactive (bool): Indicates whether to execute in interactive mode
        raise_exceptions (bool): If set to true exceptions are raised
        return_formatted (bool): If set to true, a list object is returned

    Returns:
        None
    """ # Check if the MRS metadata schema already exists
 # Make sure the MRS metadata schema exists and has the right version
 # Check if MRS is enabled
 # Get the number of enabled services

None
**kwargs
None