You are on page 1of 13

Kettle 4

2014-03-18
zhangmengzhi2005@126.com

Kettle 4

sqlserver
/
bug
A B
A B C
A B

: A B
XML A
XML XML
B B
3
Kettle!
CSV XML
CSV2XML inputdb user outputdb user
DB2DB

CSV2XML
1. CSV CSV2XML.CSV
last_name, name
Suarez,Maria
Guimaraes,Joao
Rush,Jennifer
Ortiz,Camila
Rodriguez,Carmen
da Silva,Zoe

2.

3. CSV ()Java Script () XML ()


Shift
(hop)

4. CSV2XML.CSV CSV Java Script XML

CSV
CSV

Java Script
CSV

CSV

XML
3

5.
F9-->

6.

XML CSV2XML.xml
<?xml version="1.0" encoding="GBK"?>
<Rows>
<Item><LASTNAME>Suarez</LASTNAME> <NAME>Maria</NAME> <MSG>Suarez.Maria posted a blog at
2014-02-01 15&#x3a;54&#x3a;53</MSG> </Item>
<Item><LASTNAME>Guimaraes</LASTNAME> <NAME>Joao</NAME> <MSG>Guimaraes.Joao posted a blog
at 2014-02-01 15&#x3a;54&#x3a;53</MSG> </Item>
<Item><LASTNAME>Rush</LASTNAME> <NAME>Jennifer</NAME> <MSG>Rush.Jennifer posted a blog at
2014-02-01 15&#x3a;54&#x3a;53</MSG> </Item>
<Item><LASTNAME>Ortiz</LASTNAME> <NAME>Camila</NAME> <MSG>Ortiz.Camila posted a blog at
2014-02-01 15&#x3a;54&#x3a;53</MSG> </Item>
<Item><LASTNAME>Rodriguez</LASTNAME> <NAME>Carmen</NAME> <MSG>Rodriguez.Carmen posted a
blog at 2014-02-01 15&#x3a;54&#x3a;53</MSG> </Item>
<Item><LASTNAME>da Silva</LASTNAME> <NAME>Zoe</NAME> <MSG>da Silva.Zoe posted a blog at
2014-02-01 15&#x3a;54&#x3a;53</MSG> </Item>
</Rows>

XML
Kettle4.4 Kettle4.4

Kettle4.4

DB2DB

ETL
MySQL MySQL Kettle

DB2DB inputdb user outputdb


user
1./
// root
@>mysql -u root -p
@>
// input
CREATE USER input IDENTIFIED BY 'input';
// inputdb
CREATE database inputdb;
// input
grant all privileges on inputdb.* to input identified by 'input';
//
flush privileges;
// output
CREATE USER output IDENTIFIED BY 'output';
// outputdb
CREATE database outputdb;
// output
grant all privileges on outputdb.* to output identified by 'output';
//
flush privileges;
exit;

input
// input
@>mysql -u input -p
@>
// inputdb
use inputdb;
// user
create table user (
id int not null,
userid varchar(30) not null,
username varchar(200) not null
) default charset=utf8;
//

set names gb2312;


insert into user values(1,'lisi','');
insert into user values(2,'zhangsan','');
insert into user values(3,'wangwu','');
exit;

output
// output
@>mysql -u output -p
7

@>
// outputdb
use outputdb;
// user
create table user (
id int not null,
user_id varchar(30) not null,
user_name varchar(200) not null
) default charset=utf8;
exit;

input output user


2.
MySQL JDBC jar
F:\kettle4.4\distrib\libext\JDBC
Kettle4.4 Spoon Kettle5 mysql4kettle
Kettle

admin SpoonKettle4.4
Connections Tab
inputdb/outputdb

3.
4./
Shift
(hop)
9

5./
inputdb
SQL inputdb SQL

/ outputdb
outputdb /

outputdb user /

10

6.
F9Action-->Launch
7.

outputdb user
// output
@>mysql -u output -p
@>
// outputdb
use outputdb;
//

set names gb2312;


select * from user;
11

8. Job

JobJob

9. START Transformation
Shift
(hop)

10. START Transformation


START
12

12

Transformation Kettle file repository

Kettle database
repository

11.
F9Action-->Launch

Kettle

1.
2. ETL
3. ETL

13