locked
Passing SQL Query Parameters RRS feed

  • Question

  • I'm trying to pass an input parameter that can be used in my models SQL query.  Is this possible?

    I'm using the following code to send the value.

                var inputRequest = new
                {
                    Inputs = new Dictionary<string, List<Dictionary<string, string>>>() {
                            {
                                "input1",
                                // Replace columns labels with those used in your dataset
                                new List<Dictionary<string, string>>(){new Dictionary<string, string>(){
                                        {
                                            "InputName", $"{inputValue}"
                                        }
                                    }
                                }
                            },
                        },
                    GlobalParameters = new Dictionary<string, string>() { }
                };
    
    
                var response = await client.PostAsJsonAsync("", inputRequest);
    


    David Downing

    Thursday, January 11, 2018 8:36 PM

Answers

  • Hi David,

    You *can* do what you are asking, by setting the SQL query in the reader module to be a "Web Service Parameter" in your experiment.  In the article I've linked below, there is a full walkthrough on how to do all of the steps, in this case, how to dynamically set a parameter in a *writer*, but the steps will be the same.

    I *don't* think you can parametrize *just* the WHERE clause though, you'll have to pass the full query from the application that calls the web service.

    https://blogs.technet.microsoft.com/machinelearning/2014/11/25/azureml-web-service-parameters/

    Regards,

    Sohrab

    Friday, January 12, 2018 2:44 AM
  • Providing details:

    Calling from C#:

                var inputRequest = new
                {
                    GlobalParameters = new Dictionary<string, string>() {
                            { "FirstInputQuery", $"SELECT <columns> FROM ..." },
                            { "SecondInputQuery", $"SELECT <columns> FROM ..." },
                    }
                };
    
                var response = await client.PostAsJsonAsync("", inputRequest);
    


    David Downing


    • Marked as answer by Dave Downing Wednesday, January 17, 2018 5:11 AM
    • Edited by Dave Downing Wednesday, January 17, 2018 5:12 AM
    Wednesday, January 17, 2018 5:11 AM

All replies

  • Hi David,

    You *can* do what you are asking, by setting the SQL query in the reader module to be a "Web Service Parameter" in your experiment.  In the article I've linked below, there is a full walkthrough on how to do all of the steps, in this case, how to dynamically set a parameter in a *writer*, but the steps will be the same.

    I *don't* think you can parametrize *just* the WHERE clause though, you'll have to pass the full query from the application that calls the web service.

    https://blogs.technet.microsoft.com/machinelearning/2014/11/25/azureml-web-service-parameters/

    Regards,

    Sohrab

    Friday, January 12, 2018 2:44 AM
  • Providing details:

    Calling from C#:

                var inputRequest = new
                {
                    GlobalParameters = new Dictionary<string, string>() {
                            { "FirstInputQuery", $"SELECT <columns> FROM ..." },
                            { "SecondInputQuery", $"SELECT <columns> FROM ..." },
                    }
                };
    
                var response = await client.PostAsJsonAsync("", inputRequest);
    


    David Downing


    • Marked as answer by Dave Downing Wednesday, January 17, 2018 5:11 AM
    • Edited by Dave Downing Wednesday, January 17, 2018 5:12 AM
    Wednesday, January 17, 2018 5:11 AM