logo

NJP

#Part 5 Create Load By Script Data Source

Import · May 31, 2020 · video

okay so in this part we are going to create a data source type load by script and we are going to use one part of the script that we have in flow designer that you can find in the code snippet and the rest of the script which is basically it's going to allow us to put all the data into our staging table not our target table our target table it's it's a copy 19 cases table that they have created in the beginning but before putting the data into the target table we have to put it into an intermediate table that's what we call here a staging table so let's create our data source now so look for data source on create give it a title here so I'm going to for example put get historical data import data source and then give a label for your input set table this is our staging table the intermediate table on the so getting storico data import dating table then the type is going to be load by script so custom load by script and here we are going to have the code that we have in the code snippet in flow designer okay so you can see the image that I'm going to that you will have in the resource section in order to find how you can find the code snippet okay this is the first part of the code and we have input for example here India and we and the second line here for outputs is basically we are calling the flow designer and then we have the output okay so we have created right now our datasource so we don't need anymore the value India in our flow designer here so we can take that out from here and then because we have it in our script publish it so it is entirely important to have the action to be published if you want to use it in a script okay now we are going to basically create a loop here the same way we have created a loop in in our script in flow designer to loop in the response body you know to access all the values we are going to do exactly the same thing instead of we are looping here in the country summary array that we have that the output variable so I'm creating here for loop and the loop it will go on till I mean you go and take the landing we look until the day for the full length of the country summary array okay so [Music] so we have our I equal to 0 I smaller than country summary dot length for the entire length of the country summary area I plus plus so this is our do [Music] so inside our look what we are going to have first is I'm going to just create some variables where I would like to store all the information that we are going to get for example confirm cases dead cases day country and so on so each one for each one you will have one variable and each variable we will be accessing values that we need using the country summary array so what total confirmed will be equal to clone country summary so this is our array dot confirm ok so this if you remember in the when we were creating our array country summary in the action outline the output variable they had confirmed as one of the variable so we do the same thing for the rest total power total debt for country about that okay so for everything we are accessing the bodies in this way and once you have done that we are going to create an object called map ok this object will have like name-value pairs so you under school total confirm for example will have the value of total confirmed variable that we have just created before okay so we will do the same thing for every other variable so we will have you underscore total recovered you underscore total that you are in country you underscore that a date sorry so in this way we are actually these name you are you underscore total underscore confirm this is the database sorry the field name for our staging tables all the fields that we are going to have in our staging table will have the this specific field name okay they work so it's going to be you underscore underscore so EU underscore total underscore constant u underscore total on its power will cover you and it's called total and it's called depth you underscore location you want okay so these are the fees that we will have in our staging table not our target table so we aren't going out of the loop what we are doing right now immediately so we have taken the values we have created the map object and then we are going to insert for each iteration we have to create a row in our report set table which will actually create a one record and we'll be able to have all the information and then it can go for the second interior iteration and you create the second record so here we the syntax for that is import underscore set underscore table and then insert map okay so insert parenthesis and you have the map of it save all of this so that's all you need to do in order to retrieve data for one country we will see later how we can get data for all countries it's not complicated so click on here just we are going to test if it is going to work on our so click on test load 20 recalls and see what's going to happen okay so we have a success message so we have twenty insert so let's click on import set to see see our import set and also see how the recalls that we have so recording put set row tab and these are the records that we have in our staging table so you can select any the calls that you want and see the result so I'm going to select one for example you can see or in the other the summary for 18th February and you have the number of cases that's it thanks for watching

View original source

https://www.youtube.com/watch?v=R9u0WCigTJc