PostgreSQL Reader¶
PostgreSQL Reader 插件用于从 PostgreSQL 读取数据
示例¶
假定建表语句以及输入插入语句如下:
create table if not exists addax_tbl
(
c_bigint bigint,
c_bit bit(3),
c_bool boolean,
c_byte bytea,
c_char char(10),
c_varchar varchar(20),
c_date date,
c_double float8,
c_int integer,
c_json json,
c_number decimal(8, 3),
c_real real,
c_small smallint,
c_text text,
c_ts timestamp,
c_uuid uuid,
c_xml xml,
c_money money,
c_inet inet,
c_cidr cidr,
c_macaddr macaddr
);
insert into addax_tbl
values (999988887777,
b'101',
TRUE,
'\xDEADBEEF',
'hello',
'hello, world',
'2021-01-04',
999888.9972,
9876542,
'{"bar": "baz", "balance": 7.77, "active": false}'::json,
12345.123,
123.123,
126,
'this is a long text ',
'2020-01-04 12:13:14',
'A0EEBC99-9C0B-4EF8-BB6D-6BB9BD380A11'::uuid,
'<foo>bar</foo>'::xml,
'52093.89'::money,
'192.168.1.1'::inet,
'192.168.1/24'::cidr,
'08002b:010203'::macaddr);
配置一个从PostgreSQL数据库同步抽取数据到本地的作业:
{
"job": {
"setting": {
"speed": {
"byte": -1,
"channel": 1
}
},
"content": {
"reader": {
"name": "postgresqlreader",
"parameter": {
"username": "pgtest",
"password": "pgtest",
"column": [
"*"
],
"connection": {
"table": [
"addax_tbl"
],
"jdbcUrl": "jdbc:postgresql://127.0.0.1:5432/pgtest"
}
}
},
"writer": {
"name": "streamwriter",
"parameter": {
"print": true
}
}
}
}
}
将上述配置文件保存为 job/postgres2stream.json
执行采集命令¶
执行以下命令进行数据采集
bin/addax.sh job/postgres2stream.json
参数说明¶
该插件基于 RDBMS Reader 实现,因此可以参考 RDBMS Reader 的所有配置项。