embulk-input-postgresql 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dc9510b0deb36b7e1abb4a547168f9fa7f0b501
4
- data.tar.gz: eef2d989d28a9be67496cec87cda66f67f804f63
3
+ metadata.gz: b9c87767c5c72bf9ad8fb4292916be3daa3c99c7
4
+ data.tar.gz: a16d44ad3289d71b31a19ddaa543acd980f0d3c8
5
5
  SHA512:
6
- metadata.gz: 833a8abacabb4b7063e2403bc893fd2eb7e8e2afaf44fbb46f7248f67df1021ea1ffe5677cb988cb63ff897c5500e68d19cfea1360476852c23a2affd34eeb53
7
- data.tar.gz: ba8c6bb06b50816c5b6f72df3dd2c3cc629f6519fed2460639f15fcd415dfc269d357648ebcf2ab8dae3fea4f114e30b99a9723687b7ee9a1caba53a36227ff6
6
+ metadata.gz: 106f08c0ccdac1fe0fd27b4b05a76f900149f94f7d5f66f98df40f4081294e527096c091142309fd7035cf899ba4c48d01605e6596545a191971c1765b17ac7e
7
+ data.tar.gz: c3e34e3f61e56abeec9d38d2eec1ee1518fcd4d90e64af90e436fdbd708b44e9fe4fd8b76a74c125ad80d3df32e6974c9a06ddcdb13c5800424c804269ca8b9b
data/README.md CHANGED
@@ -14,8 +14,8 @@ PostgreSQL input plugins for Embulk loads records from PostgreSQL.
14
14
  - **user**: database login user name (string, required)
15
15
  - **password**: database login password (string, default: "")
16
16
  - **database**: destination database name (string, required)
17
- - **schema**: destination name (string, default: "public")
18
- - **table**: destination name (string, required)
17
+ - **schema**: destination schema name (string, default: "public")
18
+ - **table**: destination table name (string, required)
19
19
  - **select**: comma-separated list of columns to select (string, default: "*")
20
20
  - **where**: WHERE condition to filter the rows (string, default: no-condition)
21
21
  - **fetch_rows**: number of rows to fetch one time (used for java.sql.Statement#setFetchSize) (integer, default: 10000)
@@ -6,26 +6,57 @@ import java.sql.Driver;
6
6
  import java.sql.SQLException;
7
7
  import com.google.common.base.Throwables;
8
8
  import org.embulk.config.Config;
9
+ import org.embulk.config.ConfigDefault;
9
10
  import org.embulk.input.jdbc.AbstractJdbcInputPlugin;
10
11
  import org.embulk.input.postgresql.PostgreSQLInputConnection;
11
12
 
12
13
  public class PostgreSQLInputPlugin
13
14
  extends AbstractJdbcInputPlugin
14
15
  {
15
- private static final String DEFAULT_SCHEMA = "public";
16
- private static final int DEFAULT_PORT = 5432;
17
-
18
16
  private static final Driver driver = new org.postgresql.Driver();
19
17
 
18
+ public interface PostgreSQLPluginTask
19
+ extends PluginTask
20
+ {
21
+ @Config("host")
22
+ public String getHost();
23
+
24
+ @Config("port")
25
+ @ConfigDefault("5432")
26
+ public int getPort();
27
+
28
+ @Config("user")
29
+ public String getUser();
30
+
31
+ @Config("password")
32
+ @ConfigDefault("\"\"")
33
+ public String getPassword();
34
+
35
+ @Config("database")
36
+ public String getDatabase();
37
+
38
+ @Config("schema")
39
+ @ConfigDefault("\"public\"")
40
+ public String getSchema();
41
+ }
42
+
43
+ @Override
44
+ protected Class<? extends PluginTask> getTaskClass()
45
+ {
46
+ return PostgreSQLPluginTask.class;
47
+ }
48
+
20
49
  @Override
21
50
  protected PostgreSQLInputConnection newConnection(PluginTask task) throws SQLException
22
51
  {
52
+ PostgreSQLPluginTask t = (PostgreSQLPluginTask) task;
53
+
23
54
  String url = String.format("jdbc:postgresql://%s:%d/%s",
24
- task.getHost(), task.getPort().or(DEFAULT_PORT), task.getDatabase());
55
+ t.getHost(), t.getPort(), t.getDatabase());
25
56
 
26
57
  Properties props = new Properties();
27
- props.setProperty("user", task.getUser());
28
- props.setProperty("password", task.getPassword());
58
+ props.setProperty("user", t.getUser());
59
+ props.setProperty("password", t.getPassword());
29
60
  props.setProperty("loginTimeout", "300"); // seconds
30
61
  props.setProperty("socketTimeout", "1800"); // seconds
31
62
 
@@ -34,7 +65,7 @@ public class PostgreSQLInputPlugin
34
65
  props.setProperty("tcpKeepAlive", "true");
35
66
 
36
67
  // TODO
37
- //switch task.getSssl() {
68
+ //switch t.getSssl() {
38
69
  //when "disable":
39
70
  // break;
40
71
  //when "enable":
@@ -44,11 +75,11 @@ public class PostgreSQLInputPlugin
44
75
  // break;
45
76
  //}
46
77
 
47
- props.putAll(task.getOptions());
78
+ props.putAll(t.getOptions());
48
79
 
49
80
  Connection con = driver.connect(url, props);
50
81
  try {
51
- PostgreSQLInputConnection c = new PostgreSQLInputConnection(con, task.getSchema().or(DEFAULT_SCHEMA));
82
+ PostgreSQLInputConnection c = new PostgreSQLInputConnection(con, t.getSchema());
52
83
  con = null;
53
84
  return c;
54
85
  } finally {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-postgresql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-25 00:00:00.000000000 Z
11
+ date: 2015-02-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Selects records from a table.
14
14
  email:
@@ -22,8 +22,8 @@ files:
22
22
  - lib/embulk/input/postgresql.rb
23
23
  - src/main/java/org/embulk/input/PostgreSQLInputPlugin.java
24
24
  - src/main/java/org/embulk/input/postgresql/PostgreSQLInputConnection.java
25
- - classpath/embulk-input-jdbc-0.2.3.jar
26
- - classpath/embulk-input-postgresql-0.2.3.jar
25
+ - classpath/embulk-input-jdbc-0.3.0.jar
26
+ - classpath/embulk-input-postgresql-0.3.0.jar
27
27
  - classpath/jna-4.1.0.jar
28
28
  - classpath/jna-platform-4.1.0.jar
29
29
  - classpath/postgresql-9.4-1200-jdbc41.jar