Reading from database tables
Now that we have the Talend schemas available, we can start to use them to access the data in the database.
Getting ready
Create a job jo_cook_ch07_0010_readTables
.
How to do it…
The default mode of reading a table in Talend is to read all the rows and columns of a table:
Drag the
customer
table from the left-hand side panel. This will open up a list of options.Select tMysqlInput.
Add a
tLogRow
component and create a flow betweentMysqlInput
andtLogRow
. Change the Mode oftLogRow
to table.Run the job and you will see that the complete table has been read.
Selected rows and columns
In many cases we do not want the whole table, so it is more efficient to filter the data in the database via a query:
Open
tMysqlInput
and change the query to:" SELECT `customer`.`name`, `customer`.`countryOfResidence` FROM `customer` WHERE `customer`.`countryOfResidence` = 'USA' "
Open the schema, change the type to built-in, and remove the
customerId
field.Click on the guess schema...