回答編集履歴
2
ストア°プロシージャを追記
test
CHANGED
@@ -167,3 +167,39 @@
|
|
167
167
|
after_load: insert into imagedst(id,image) select id,FROM_BASE64(image) from imagetemp;
|
168
168
|
|
169
169
|
```
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
## 2021/06/17 追記
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
複数SQLの件は、ストアドプロシージャーが良いように思います。
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
```sql
|
184
|
+
|
185
|
+
delimiter //
|
186
|
+
|
187
|
+
create PROCEDURE sync_image_table ()
|
188
|
+
|
189
|
+
begin
|
190
|
+
|
191
|
+
delete from imagedst;
|
192
|
+
|
193
|
+
insert into imagedst(id,image) select id,FROM_BASE64(image) from imagetemp;
|
194
|
+
|
195
|
+
end//
|
196
|
+
|
197
|
+
```
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
```yaml
|
202
|
+
|
203
|
+
after_load: call sync_image_table()
|
204
|
+
|
205
|
+
```
|
1
補足の追記
test
CHANGED
@@ -97,3 +97,73 @@
|
|
97
97
|
* 設定ファイル(機密情報等はマスク)
|
98
98
|
|
99
99
|
* テーブル定義(サンプル等)
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
## 2021/06/15 追記
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
できそうなのはこんな感じです。
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
```sql
|
114
|
+
|
115
|
+
create table imagetest(id int not null primary key, image MEDIUMBLOB not null);
|
116
|
+
|
117
|
+
insert into imagetest(id,image) values(1,LOAD_FILE('/path/to/image'));
|
118
|
+
|
119
|
+
create table imagedst(id int not null primary key, image MEDIUMBLOB not null);
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
```yaml
|
126
|
+
|
127
|
+
in:
|
128
|
+
|
129
|
+
type: mysql
|
130
|
+
|
131
|
+
user: user
|
132
|
+
|
133
|
+
password: password
|
134
|
+
|
135
|
+
database: embulk_test
|
136
|
+
|
137
|
+
table: imagetest
|
138
|
+
|
139
|
+
host: host
|
140
|
+
|
141
|
+
select: id,TO_BASE64(image) as image
|
142
|
+
|
143
|
+
out:
|
144
|
+
|
145
|
+
type: mysql
|
146
|
+
|
147
|
+
user: user
|
148
|
+
|
149
|
+
password: password
|
150
|
+
|
151
|
+
database: embulk_test
|
152
|
+
|
153
|
+
table: imagetemp
|
154
|
+
|
155
|
+
column_options:
|
156
|
+
|
157
|
+
image:
|
158
|
+
|
159
|
+
type: longtext
|
160
|
+
|
161
|
+
host: host
|
162
|
+
|
163
|
+
mode: replace
|
164
|
+
|
165
|
+
# ここは入れ替えするか挿入するか等によって修正
|
166
|
+
|
167
|
+
after_load: insert into imagedst(id,image) select id,FROM_BASE64(image) from imagetemp;
|
168
|
+
|
169
|
+
```
|