Skip to content

create_data_source_from_rds

create_data_source_from_rds(
    data_source_id: EntityId,
    rds_data: RDSDataSpec,
    role_arn: RoleARN,
    *,
    config_overrides: Optional[MachineLearningClientConfig] = None,
    data_source_name: Optional[EntityName] = None,
    compute_statistics: Optional[ComputeStatistics] = None,
) -> CreateDataSourceFromRDSOutput

Creates a DataSource object from an Amazon Relational Database Service (Amazon RDS). A DataSource references data that can be used to perform CreateMLModel, CreateEvaluation, or CreateBatchPrediction operations.

CreateDataSourceFromRDS is an asynchronous operation. In response to CreateDataSourceFromRDS, Amazon Machine Learning (Amazon ML) immediately returns and sets the DataSource status to PENDING. After the DataSource is created and ready for use, Amazon ML sets the Status parameter to COMPLETED. DataSource in the COMPLETED or PENDING state can be used only to perform >CreateMLModel>, CreateEvaluation, or CreateBatchPrediction operations.

If Amazon ML cannot accept the input source, it sets the Status parameter to FAILED and includes an error message in the Message attribute of the GetDataSource operation response.

Parameters:

  • data_source_id (EntityId) –

    A user-supplied ID that uniquely identifies the DataSource. Typically, an Amazon Resource Number (ARN) becomes the ID for a DataSource.

  • data_source_name (Optional[EntityName], default: None ) –

    A user-supplied name or description of the DataSource.

  • rds_data (RDSDataSpec) –

    The data specification of an Amazon RDS DataSource:

    • DatabaseInformation -

      • DatabaseName - The name of the Amazon RDS database.

      • InstanceIdentifier - A unique identifier for the Amazon RDS database instance.

    • DatabaseCredentials - AWS Identity and Access Management (IAM) credentials that are used to connect to the Amazon RDS database.

    • ResourceRole - A role (DataPipelineDefaultResourceRole) assumed by an EC2 instance to carry out the copy task from Amazon RDS to Amazon Simple Storage Service (Amazon S3). For more information, see Role templates for data pipelines.

    • ServiceRole - A role (DataPipelineDefaultRole) assumed by the AWS Data Pipeline service to monitor the progress of the copy task from Amazon RDS to Amazon S3. For more information, see Role templates for data pipelines.

    • SecurityInfo - The security information to use to access an RDS DB instance. You need to set up appropriate ingress rules for the security entity IDs provided to allow access to the Amazon RDS instance. Specify a [SubnetId, SecurityGroupIds] pair for a VPC-based RDS DB instance.

    • SelectSqlQuery - A query that is used to retrieve the observation data for the Datasource.

    • S3StagingLocation - The Amazon S3 location for staging Amazon RDS data. The data retrieved from Amazon RDS using SelectSqlQuery is stored in this location.

    • DataSchemaUri - The Amazon S3 location of the DataSchema.

    • DataSchema - A JSON string representing the schema. This is not required if DataSchemaUri is specified.

    • DataRearrangement - A JSON string that represents the splitting and rearrangement requirements for the Datasource.

      Sample - "{\"splitting\":{\"percentBegin\":10,\"percentEnd\":60}}"

  • role_arn (RoleARN) –

    The role that Amazon ML assumes on behalf of the user to create and activate a data pipeline in the user's account and copy data using the SelectSqlQuery query from Amazon RDS to Amazon S3.

  • compute_statistics (Optional[ComputeStatistics], default: None ) –

    The compute statistics for a DataSource. The statistics are generated from the observation data referenced by a DataSource. Amazon ML uses the statistics internally during MLModel training. This parameter must be set to true if the DataSource needs to be used for MLModel training.

Raises:

  • IdempotentParameterMismatchException –

    A second request to use or change an object was not allowed. This can result from retrying a request using a parameter that was not present in the original request.

  • InternalServerException –

    An error on the server occurred when trying to process a request.

  • InvalidInputException –

    An error on the client occurred. Typically, the cause is an invalid input value.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_machine_learning/_services/machine_learning.py
def create_data_source_from_rds(
    self,
    data_source_id: "capo_machine_learning.types.entity_id.EntityId",
    rds_data: "capo_machine_learning.types.rds_data_spec.RDSDataSpec",
    role_arn: "capo_machine_learning.types.role_arn.RoleARN",
    *,
    config_overrides: Optional[MachineLearningClientConfig] = None,
    data_source_name: Optional[
        "capo_machine_learning.types.entity_name.EntityName"
    ] = None,
    compute_statistics: Optional[
        "capo_machine_learning.types.compute_statistics.ComputeStatistics"
    ] = None,
) -> "capo_machine_learning.types.create_data_source_from_rds_output.CreateDataSourceFromRDSOutput":
    r"""<p>Creates a <code>DataSource</code> object from an <a href="http://aws.amazon.com/rds/"> Amazon Relational Database Service</a> (Amazon RDS). A <code>DataSource</code> references data that can be used to perform <code>CreateMLModel</code>, <code>CreateEvaluation</code>, or <code>CreateBatchPrediction</code> operations.</p> <p> <code>CreateDataSourceFromRDS</code> is an asynchronous operation. In response to <code>CreateDataSourceFromRDS</code>, Amazon Machine Learning (Amazon ML) immediately returns and sets the <code>DataSource</code> status to <code>PENDING</code>. After the <code>DataSource</code> is created and ready for use, Amazon ML sets the <code>Status</code> parameter to <code>COMPLETED</code>. <code>DataSource</code> in the <code>COMPLETED</code> or <code>PENDING</code> state can be used only to perform <code>>CreateMLModel</code>>, <code>CreateEvaluation</code>, or <code>CreateBatchPrediction</code> operations. </p> <p> If Amazon ML cannot accept the input source, it sets the <code>Status</code> parameter to <code>FAILED</code> and includes an error message in the <code>Message</code> attribute of the <code>GetDataSource</code> operation response. </p>

    Args:
        data_source_id: <p>A user-supplied ID that uniquely identifies the <code>DataSource</code>. Typically, an Amazon Resource Number (ARN) becomes the ID for a <code>DataSource</code>.</p>
        data_source_name: <p>A user-supplied name or description of the <code>DataSource</code>.</p>
        rds_data: <p>The data specification of an Amazon RDS <code>DataSource</code>:</p> <ul> <li> <p>DatabaseInformation -</p> <ul> <li> <p> <code>DatabaseName</code> - The name of the Amazon RDS database.</p> </li> <li> <p> <code>InstanceIdentifier </code> - A unique identifier for the Amazon RDS database instance.</p> </li> </ul> </li> <li> <p>DatabaseCredentials - AWS Identity and Access Management (IAM) credentials that are used to connect to the Amazon RDS database.</p> </li> <li> <p>ResourceRole - A role (DataPipelineDefaultResourceRole) assumed by an EC2 instance to carry out the copy task from Amazon RDS to Amazon Simple Storage Service (Amazon S3). For more information, see <a href="https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-iam-roles.html">Role templates</a> for data pipelines.</p> </li> <li> <p>ServiceRole - A role (DataPipelineDefaultRole) assumed by the AWS Data Pipeline service to monitor the progress of the copy task from Amazon RDS to Amazon S3. For more information, see <a href="https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-iam-roles.html">Role templates</a> for data pipelines.</p> </li> <li> <p>SecurityInfo - The security information to use to access an RDS DB instance. You need to set up appropriate ingress rules for the security entity IDs provided to allow access to the Amazon RDS instance. Specify a [<code>SubnetId</code>, <code>SecurityGroupIds</code>] pair for a VPC-based RDS DB instance.</p> </li> <li> <p>SelectSqlQuery - A query that is used to retrieve the observation data for the <code>Datasource</code>.</p> </li> <li> <p>S3StagingLocation - The Amazon S3 location for staging Amazon RDS data. The data retrieved from Amazon RDS using <code>SelectSqlQuery</code> is stored in this location.</p> </li> <li> <p>DataSchemaUri - The Amazon S3 location of the <code>DataSchema</code>.</p> </li> <li> <p>DataSchema - A JSON string representing the schema. This is not required if <code>DataSchemaUri</code> is specified. </p> </li> <li> <p>DataRearrangement - A JSON string that represents the splitting and rearrangement requirements for the <code>Datasource</code>. </p> <p> Sample - <code> "{\"splitting\":{\"percentBegin\":10,\"percentEnd\":60}}"</code> </p> </li> </ul>
        role_arn: <p>The role that Amazon ML assumes on behalf of the user to create and activate a data pipeline in the user's account and copy data using the <code>SelectSqlQuery</code> query from Amazon RDS to Amazon S3.</p> <p></p>
        compute_statistics: <p>The compute statistics for a <code>DataSource</code>. The statistics are generated from the observation data referenced by a <code>DataSource</code>. Amazon ML uses the statistics internally during <code>MLModel</code> training. This parameter must be set to <code>true</code> if the <code></code>DataSource<code></code> needs to be used for <code>MLModel</code> training. </p>

    Raises:
        capo_machine_learning.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>A second request to use or change an object was not allowed. This can result from retrying a request using a parameter that was not present in the original request.</p>
        capo_machine_learning.errors.internal_server_exception.InternalServerException: <p>An error on the server occurred when trying to process a request.</p>
        capo_machine_learning.errors.invalid_input_exception.InvalidInputException: <p>An error on the client occurred. Typically, the cause is an invalid input value.</p>
        capo_machine_learning.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_machine_learning.types.create_data_source_from_rds_input.CreateDataSourceFromRDSInput]",
    ) -> OperationResponse[
        "capo_machine_learning.types.create_data_source_from_rds_output.CreateDataSourceFromRDSOutput"
    ]:
        import capo_machine_learning._operations.amazon_ml_20141212.create_data_source_from_rds

        output, http_response = (
            capo_machine_learning._operations.amazon_ml_20141212.create_data_source_from_rds.create_data_source_from_rds(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_machine_learning.types.create_data_source_from_rds_input.CreateDataSourceFromRDSInput",
    ) -> dict[str, Any]:
        import capo_machine_learning.types.create_data_source_from_rds_input

        return capo_machine_learning.types.create_data_source_from_rds_input.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateDataSourceFromRDS", redact_input=_redact_input),
    )
    input_: capo_machine_learning.types.create_data_source_from_rds_input.CreateDataSourceFromRDSInput = {
        "data_source_id": data_source_id,
        "rds_data": rds_data,
        "role_arn": role_arn,
    }
    if data_source_name is not None:
        input_["data_source_name"] = data_source_name
    if compute_statistics is not None:
        input_["compute_statistics"] = compute_statistics

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output