Handling customer data is very key and sometimes, you do not want to use your real customer’s data and information during development. However you would want to generate some dummy data in Talend and use for your development and testing purposes.
In this short tutorial, we are going to use TRowGenerator in Talend and then insert the data into a PostgreSQL database’ table.
- First let’s create our job and give it a name example, GenerateDummyCustomerData
- Now let’s go to the Palette and under the Misc group of components let’s pick and drop the TRowGenerator on the workbench
- Let’s select the TRowGenerator component and edit its schema
- Now let’s define how we are going to generate the data by clicking on the …. next to the RowGenerator Editor
- We are going to use Talend Inbuilt functions for generating data for our schema. Hence will use Numeric.Sequence for the CustomerID which will give us a incremental integers for our CustomerId field. So all our schema will be filled with data with these functions: FirstName = TalendDataGenerator.getFirstName() ; LastName= TalendDataGenerator.getLastName(); State = TalendDataGenerator.getUsState()
- Now let’s create a table in PostgreSQL database and call it CustomerDummyData and import the schema into Talend
- Let’s define the columns to be same as our talend TRowGenerator schema
- Now in Talend let’s go to Metadata and connect to our PostgreSQL database and schema and then retrieve the schema of the newly created table
- Follow the onscreen instructions to retrieve the table name and schema
- Now that we have our schema imported lets drag it onto our workbench as our output component by chosing tPostgresqlOutput component from the pop up window
- Now let’s connect our TRowGenerator to our PostgreSQL output component. You will be asked if ” you want to get the schema of the output component.” It is better to get the the schema by clicking YES as the schema are the same or you can ignore (note : if you click yes, you will have re-select your data generating functions again)
- Re-select the data generating functions again if you clicked YES and you can also change the number of rows you want to generate as in the image below:
- Now run your job
- Job should run fine. You can now check your dummy data outputted in your PostgreSQL database table CustomerDummyData
- Hope this helps
- Summary: 1 .You learned a simple way to generate sample data through talend for development purposes 2. You learned how to insert the data into a PostgreSQL database
If you have any questions or other ways of achieving similar thing, please leave your comments in the comment box below