embulk-input-mysql 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 80a7efb67fd248f081a40332fba755bbc8c3f0b6
4
+ data.tar.gz: 5e976132928913f5aff89ca4a4db05a64b94233b
5
+ SHA512:
6
+ metadata.gz: bbc49360183a70ca8caa434a3a6c7812b6b5ff32e4125067094133fd9f8c6472486f36f436b8c9378c1f86e7bcd9cf6a60c87341877eb5990840e5adf943c5cf
7
+ data.tar.gz: 4d6ee1ec8745ca3f28f0e04075b093e03d5599b9bc22a37a5870971794ee5df352b2df06da78edbdda9e8ddf8c9a7ff0a8b2feb2dbb3e610999e01f081c6c5c5
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # MySQL input plugins for Embulk
2
+
3
+ MySQL input plugins for Embulk loads records from MySQL.
4
+
5
+ ## Overview
6
+
7
+ * **Plugin type**: input
8
+ * **Resume supported**: yes
9
+
10
+ ## Configuration
11
+
12
+ - **host**: database host name (string, required)
13
+ - **port**: database port number (integer, 3306)
14
+ - **user**: database login user name (string, required)
15
+ - **password**: database login password (string, default: "")
16
+ - **database**: destination database name (string, required)
17
+ - **table**: destination name (string, required)
18
+ - **select**: comma-separated list of columns to select (string, default: "*")
19
+ - **where**: WHERE condition to filter the rows (string, default: no-condition)
20
+ - **fetch_rows**: number of rows to fetch one time (used for java.sql.Statement#setFetchSize) (integer, default: 10000)
21
+ - **options**: extra JDBC properties (hash, default: {})
22
+
23
+ ## Example
24
+
25
+ ```yaml
26
+ in:
27
+ type: mysql
28
+ host: localhost
29
+ user: myuser
30
+ password: ""
31
+ database: my_database
32
+ table: my_table
33
+ select: "col1, col2, col3"
34
+ where: "col4 != 'a'"
35
+ ```
36
+
37
+ ## Build
38
+
39
+ ```
40
+ $ ./gradlew gem
41
+ ```
data/build.gradle ADDED
@@ -0,0 +1,7 @@
1
+ dependencies {
2
+ compile project(':embulk-input-jdbc')
3
+
4
+ compile 'mysql:mysql-connector-java:5.1.34'
5
+
6
+ testCompile project(':embulk-input-jdbc').sourceSets.test.output
7
+ }
@@ -0,0 +1,3 @@
1
+ Embulk::JavaPlugin.register_input(
2
+ :mysql, "org.embulk.input.MySQLInputPlugin",
3
+ File.expand_path('../../../../classpath', __FILE__))
@@ -0,0 +1,73 @@
1
+ package org.embulk.input;
2
+
3
+ import java.util.Properties;
4
+ import java.sql.Connection;
5
+ import java.sql.Driver;
6
+ import java.sql.SQLException;
7
+ import com.google.common.base.Throwables;
8
+ import org.embulk.config.Config;
9
+ import org.embulk.input.jdbc.AbstractJdbcInputPlugin;
10
+ import org.embulk.input.mysql.MySQLInputConnection;
11
+
12
+ public class MySQLInputPlugin
13
+ extends AbstractJdbcInputPlugin
14
+ {
15
+ private static final int DEFAULT_PORT = 3306;
16
+
17
+ @Override
18
+ protected MySQLInputConnection newConnection(PluginTask task) throws SQLException
19
+ {
20
+ String url = String.format("jdbc:mysql://%s:%d/%s",
21
+ task.getHost(), task.getPort().or(DEFAULT_PORT), task.getDatabase());
22
+
23
+ Properties props = new Properties();
24
+ props.setProperty("user", task.getUser());
25
+ props.setProperty("password", task.getPassword());
26
+
27
+ props.setProperty("rewriteBatchedStatements", "true");
28
+ props.setProperty("useCompression", "true");
29
+
30
+ props.setProperty("connectTimeout", "300000"); // milliseconds
31
+ props.setProperty("socketTimeout", "1800000"); // smillieconds
32
+
33
+ // Enable keepalive based on tcp_keepalive_time, tcp_keepalive_intvl and tcp_keepalive_probes kernel parameters.
34
+ // Socket options TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL are not configurable.
35
+ props.setProperty("tcpKeepAlive", "true");
36
+
37
+ // TODO
38
+ //switch task.getSssl() {
39
+ //when "disable":
40
+ // break;
41
+ //when "enable":
42
+ // props.setProperty("useSSL", "true");
43
+ // props.setProperty("requireSSL", "false");
44
+ // props.setProperty("verifyServerCertificate", "false");
45
+ // break;
46
+ //when "verify":
47
+ // props.setProperty("useSSL", "true");
48
+ // props.setProperty("requireSSL", "true");
49
+ // props.setProperty("verifyServerCertificate", "true");
50
+ // break;
51
+ //}
52
+
53
+ props.putAll(task.getOptions());
54
+
55
+ Driver driver;
56
+ try {
57
+ driver = new com.mysql.jdbc.Driver(); // new com.mysql.jdbc.Driver throws SQLException
58
+ } catch (SQLException ex) {
59
+ throw new RuntimeException(ex);
60
+ }
61
+
62
+ Connection con = driver.connect(url, props);
63
+ try {
64
+ MySQLInputConnection c = new MySQLInputConnection(con);
65
+ con = null;
66
+ return c;
67
+ } finally {
68
+ if (con != null) {
69
+ con.close();
70
+ }
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,16 @@
1
+ package org.embulk.input.mysql;
2
+
3
+ import java.sql.Connection;
4
+ import java.sql.PreparedStatement;
5
+ import java.sql.SQLException;
6
+ import org.embulk.input.jdbc.JdbcInputConnection;
7
+
8
+ public class MySQLInputConnection
9
+ extends JdbcInputConnection
10
+ {
11
+ public MySQLInputConnection(Connection connection)
12
+ throws SQLException
13
+ {
14
+ super(connection, null);
15
+ }
16
+ }
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: embulk-input-mysql
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - FURUHASHI Sadayuki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: JDBC input plugin is an Embulk plugin that loads records from JDBC so that any output plugins can receive the records. Search the output plugins by "embulk-output" keyword.
14
+ email:
15
+ - frsyuki@users.sourceforge.jp
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - README.md
21
+ - build.gradle
22
+ - lib/embulk/input/mysql.rb
23
+ - src/main/java/org/embulk/input/MySQLInputPlugin.java
24
+ - src/main/java/org/embulk/input/mysql/MySQLInputConnection.java
25
+ - classpath/embulk-input-jdbc-0.1.0.jar
26
+ - classpath/embulk-input-mysql-0.1.0.jar
27
+ - classpath/mysql-connector-java-5.1.34.jar
28
+ homepage: https://github.com/embulk/embulk-input-jdbc
29
+ licenses:
30
+ - Apache 2.0
31
+ metadata: {}
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 2.1.9
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: JDBC input plugin for Embulk
52
+ test_files: []