@bkmj/node-red-contrib-odbcmj 1.7.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -28
- package/odbc.html +261 -260
- package/odbc.js +259 -536
- package/package.json +26 -7
package/odbc.html
CHANGED
|
@@ -1,167 +1,294 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
2
|
RED.nodes.registerType("odbc config", {
|
|
3
3
|
category: "config",
|
|
4
|
+
credentials: {
|
|
5
|
+
password: { type: "password" }
|
|
6
|
+
},
|
|
4
7
|
defaults: {
|
|
5
|
-
connectionString: { value: "", required: true },
|
|
6
8
|
name: { value: "" },
|
|
9
|
+
connectionMode: { value: "structured" },
|
|
10
|
+
dbType: { value: "sqlserver" },
|
|
11
|
+
driver: { value: "" },
|
|
12
|
+
server: { value: "" },
|
|
13
|
+
database: { value: "" },
|
|
14
|
+
user: { value: "" },
|
|
15
|
+
connectionString: { value: "" },
|
|
7
16
|
initialSize: { value: 5 },
|
|
8
17
|
incrementSize: { value: 5 },
|
|
9
18
|
maxSize: { value: 15 },
|
|
10
19
|
shrink: { value: true },
|
|
11
|
-
syntaxtick: { value: false },
|
|
12
|
-
syntax: { value: "mysql" },
|
|
13
20
|
connectionTimeout: { value: 3 },
|
|
14
21
|
loginTimeout: { value: 3 },
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
retryFreshConnection: { value: false },
|
|
23
|
+
retryDelay: { value: 5, validate: RED.validators.number() },
|
|
24
|
+
retryOnMsg: { value: true },
|
|
25
|
+
syntaxtick: { value: false },
|
|
26
|
+
syntax: { value: "mysql" },
|
|
17
27
|
},
|
|
18
28
|
label: function () {
|
|
19
29
|
return this.name || "odbc config";
|
|
20
30
|
},
|
|
21
31
|
oneditprepare: function () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
var node = this;
|
|
33
|
+
|
|
34
|
+
// --- Logique pour les sections déroulantes ---
|
|
35
|
+
// On ajoute un écouteur de clic sur les en-têtes de section
|
|
36
|
+
$('.form-section-header').on('click', function() {
|
|
37
|
+
$(this).toggleClass('expanded');
|
|
38
|
+
// On fait basculer le conteneur d'options qui suit immédiatement l'en-tête
|
|
39
|
+
$(this).next('.form-section-content').slideToggle();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// --- Logique pour le mode de connexion hybride ---
|
|
43
|
+
function toggleConnectionMode(mode) {
|
|
44
|
+
if (mode === 'structured') {
|
|
45
|
+
$(".config-mode-structured").show();
|
|
46
|
+
$(".config-mode-string").hide();
|
|
47
|
+
} else {
|
|
48
|
+
$(".config-mode-structured").hide();
|
|
49
|
+
$(".config-mode-string").show();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function toggleDriverField(dbType) {
|
|
53
|
+
if (dbType === 'other') {
|
|
54
|
+
$("#node-config-driver-row").show();
|
|
26
55
|
} else {
|
|
27
|
-
$("
|
|
56
|
+
$("#node-config-driver-row").hide();
|
|
28
57
|
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
$("#node-config-input-connectionMode").on("change", function() {
|
|
61
|
+
toggleConnectionMode($(this).val());
|
|
62
|
+
}).trigger("change");
|
|
63
|
+
|
|
64
|
+
$("#node-config-input-dbType").on("change", function() {
|
|
65
|
+
toggleDriverField($(this).val());
|
|
66
|
+
}).trigger("change");
|
|
67
|
+
|
|
68
|
+
// --- Logiques pour les cases à cocher ---
|
|
69
|
+
$("#node-config-input-syntaxtick").on("change", function () {
|
|
70
|
+
$(".input-syntax").toggle(this.checked);
|
|
71
|
+
}).trigger("change");
|
|
72
|
+
|
|
73
|
+
$("#node-config-input-retryFreshConnection").on("change", function() {
|
|
74
|
+
$(".retry-options").toggle(this.checked);
|
|
75
|
+
}).trigger("change");
|
|
76
|
+
|
|
77
|
+
// --- Logique pour le bouton de test ---
|
|
78
|
+
$('#node-config-test-connection').on('click', function() {
|
|
79
|
+
var button = $(this);
|
|
80
|
+
var originalText = "Test Connection";
|
|
81
|
+
var icon = button.find("i");
|
|
82
|
+
icon.removeClass('fa-bolt').addClass('fa-spinner fa-spin');
|
|
83
|
+
button.text(' Testing...').prop('disabled', true);
|
|
84
|
+
|
|
85
|
+
var connectionMode = $("#node-config-input-connectionMode").val();
|
|
86
|
+
|
|
87
|
+
// --- CORRECTION : Récupérer le bon mot de passe selon le mode ---
|
|
88
|
+
var password = (connectionMode === 'structured')
|
|
89
|
+
? $("#node-config-input-password-structured").val()
|
|
90
|
+
: $("#node-config-input-password-string").val();
|
|
91
|
+
|
|
92
|
+
var configData = {
|
|
93
|
+
connectionMode: connectionMode,
|
|
94
|
+
dbType: $("#node-config-input-dbType").val(),
|
|
95
|
+
driver: $("#node-config-input-driver").val(),
|
|
96
|
+
server: $("#node-config-input-server").val(),
|
|
97
|
+
database: $("#node-config-input-database").val(),
|
|
98
|
+
user: $("#node-config-input-user").val(),
|
|
99
|
+
password: password,
|
|
100
|
+
connectionString: $("#node-config-input-connectionString").val()
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
$.ajax({
|
|
104
|
+
url: "odbc_config/" + node.id + "/test",
|
|
105
|
+
type: "POST",
|
|
106
|
+
contentType: "application/json",
|
|
107
|
+
data: JSON.stringify(configData),
|
|
108
|
+
success: function(result) {
|
|
109
|
+
RED.notify("Connection successful!", {type:"success", timeout: 2000});
|
|
110
|
+
},
|
|
111
|
+
error: function(xhr, status, error) {
|
|
112
|
+
var errMsg = xhr.responseText || "Connection failed. Check Node-RED logs for details.";
|
|
113
|
+
RED.notify("Connection failed: " + errMsg, {type:"error", timeout: 4000});
|
|
114
|
+
},
|
|
115
|
+
complete: function() {
|
|
116
|
+
button.text(originalText).prop('disabled', false);
|
|
117
|
+
icon.removeClass('fa-spinner fa-spin').addClass('fa-bolt');
|
|
118
|
+
}
|
|
119
|
+
});
|
|
29
120
|
});
|
|
30
121
|
},
|
|
31
122
|
});
|
|
32
123
|
</script>
|
|
33
124
|
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
125
|
+
<style>
|
|
126
|
+
.form-section-header {
|
|
127
|
+
cursor: pointer;
|
|
128
|
+
padding: 5px;
|
|
129
|
+
border-bottom: 1px solid #ddd;
|
|
130
|
+
margin-bottom: 10px;
|
|
131
|
+
}
|
|
132
|
+
.form-section-header i.fa-caret-right {
|
|
133
|
+
transition: transform 0.2s ease-in-out;
|
|
134
|
+
}
|
|
135
|
+
.form-section-header.expanded i.fa-caret-right {
|
|
136
|
+
transform: rotate(90deg);
|
|
137
|
+
}
|
|
138
|
+
.form-section-content {
|
|
139
|
+
padding-left: 20px;
|
|
140
|
+
}
|
|
141
|
+
</style>
|
|
41
142
|
|
|
143
|
+
<script type="text/html" data-template-name="odbc config">
|
|
42
144
|
<div class="form-row">
|
|
43
|
-
<label for="node-config-input-
|
|
44
|
-
|
|
45
|
-
>
|
|
46
|
-
<input
|
|
47
|
-
type="text"
|
|
48
|
-
id="node-config-input-connectionString"
|
|
49
|
-
placeholder="DSN=...;"
|
|
50
|
-
/>
|
|
145
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
146
|
+
<input type="text" id="node-config-input-name" placeholder="My DB Connection">
|
|
51
147
|
</div>
|
|
52
148
|
|
|
53
149
|
<div class="form-row">
|
|
54
|
-
<label for="node-config-input-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
id="node-config-input-initialSize"
|
|
60
|
-
placeholder="5"
|
|
61
|
-
/>
|
|
150
|
+
<label for="node-config-input-connectionMode"><i class="fa fa-cogs"></i> Mode</label>
|
|
151
|
+
<select id="node-config-input-connectionMode">
|
|
152
|
+
<option value="structured">Structured Fields (Recommended)</option>
|
|
153
|
+
<option value="string">Connection String (Advanced)</option>
|
|
154
|
+
</select>
|
|
62
155
|
</div>
|
|
63
156
|
|
|
64
|
-
<div class="
|
|
65
|
-
<
|
|
66
|
-
><i class="fa fa-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
157
|
+
<div class="config-mode-structured">
|
|
158
|
+
<div class="form-row">
|
|
159
|
+
<label for="node-config-input-dbType"><i class="fa fa-database"></i> Database Type</label>
|
|
160
|
+
<select id="node-config-input-dbType">
|
|
161
|
+
<option value="sqlserver">SQL Server</option>
|
|
162
|
+
<option value="postgresql">PostgreSQL</option>
|
|
163
|
+
<option value="mysql">MySQL</option>
|
|
164
|
+
<option value="other">Other (Specify Driver)</option>
|
|
165
|
+
</select>
|
|
166
|
+
</div>
|
|
167
|
+
<div class="form-row" id="node-config-driver-row">
|
|
168
|
+
<label for="node-config-input-driver"><i class="fa fa-info-circle"></i> Driver</label>
|
|
169
|
+
<input type="text" id="node-config-input-driver" placeholder="e.g., IBM i Access ODBC Driver">
|
|
170
|
+
</div>
|
|
171
|
+
<div class="form-row">
|
|
172
|
+
<label for="node-config-input-server"><i class="fa fa-server"></i> Server</label>
|
|
173
|
+
<input type="text" id="node-config-input-server" placeholder="hostname_or_ip,port">
|
|
174
|
+
</div>
|
|
175
|
+
<div class="form-row">
|
|
176
|
+
<label for="node-config-input-database"><i class="fa fa-table"></i> Database</label>
|
|
177
|
+
<input type="text" id="node-config-input-database" placeholder="(optional)">
|
|
178
|
+
</div>
|
|
179
|
+
<div class="form-row">
|
|
180
|
+
<label for="node-config-input-user"><i class="fa fa-user"></i> User</label>
|
|
181
|
+
<input type="text" id="node-config-input-user">
|
|
182
|
+
</div>
|
|
183
|
+
<div class="form-row">
|
|
184
|
+
<label for="node-config-input-password-structured"><i class="fa fa-lock"></i> Password</label>
|
|
185
|
+
<input type="password" id="node-config-input-password-structured">
|
|
186
|
+
</div>
|
|
73
187
|
</div>
|
|
74
|
-
|
|
75
|
-
<div class="
|
|
76
|
-
<
|
|
77
|
-
><i class="fa fa-
|
|
78
|
-
|
|
79
|
-
|
|
188
|
+
|
|
189
|
+
<div class="config-mode-string">
|
|
190
|
+
<div class="form-row">
|
|
191
|
+
<label for="node-config-input-connectionString"><i class="fa fa-font"></i> Connection String</label>
|
|
192
|
+
<input type="text" id="node-config-input-connectionString" placeholder="DRIVER={...};PWD={{{password}}};">
|
|
193
|
+
</div>
|
|
194
|
+
<div class="form-row">
|
|
195
|
+
<label for="node-config-input-password-string"><i class="fa fa-lock"></i> Password</label>
|
|
196
|
+
<input type="password" id="node-config-input-password-string">
|
|
197
|
+
<span class="form-tips">Use <code>{{{password}}}</code> placeholder in the string above.</span>
|
|
198
|
+
</div>
|
|
80
199
|
</div>
|
|
81
200
|
|
|
82
201
|
<div class="form-row">
|
|
83
|
-
<label
|
|
84
|
-
|
|
85
|
-
>
|
|
86
|
-
<input
|
|
87
|
-
type="checkbox"
|
|
88
|
-
id="node-config-input-shrink"
|
|
89
|
-
style="margin-left:0px; vertical-align:top; width:auto !important;"
|
|
90
|
-
/>
|
|
202
|
+
<label> </label>
|
|
203
|
+
<button class="ui-button" id="node-config-test-connection" style="width: auto;"><i class="fa fa-bolt"></i> Test Connection</button>
|
|
91
204
|
</div>
|
|
92
205
|
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
id="node-config-input-
|
|
100
|
-
|
|
101
|
-
|
|
206
|
+
<hr/>
|
|
207
|
+
|
|
208
|
+
<div class="form-section-header expanded"><h4><i class="fa fa-caret-right"></i> <i class="fa fa-sitemap"></i> Pool Options</h4></div>
|
|
209
|
+
<div class="form-section-content">
|
|
210
|
+
<div class="form-row">
|
|
211
|
+
<label for="node-config-input-initialSize"><i class="fa fa-play"></i> Initial Size</label>
|
|
212
|
+
<input type="number" id="node-config-input-initialSize" placeholder="5" />
|
|
213
|
+
</div>
|
|
214
|
+
<div class="form-row">
|
|
215
|
+
<label for="node-config-input-incrementSize"><i class="fa fa-plus"></i> Increment Size</label>
|
|
216
|
+
<input type="number" id="node-config-input-incrementSize" placeholder="5" />
|
|
217
|
+
</div>
|
|
218
|
+
<div class="form-row">
|
|
219
|
+
<label for="node-config-input-maxSize"><i class="fa fa-stop"></i> Max Size</label>
|
|
220
|
+
<input type="number" id="node-config-input-maxSize" placeholder="15" />
|
|
221
|
+
</div>
|
|
222
|
+
<div class="form-row">
|
|
223
|
+
<label for="node-config-input-shrink"><i class="fa fa-compress"></i> Shrink Pool</label>
|
|
224
|
+
<input type="checkbox" id="node-config-input-shrink" style="margin-left:0px; vertical-align:top; width:auto !important;" />
|
|
225
|
+
</div>
|
|
226
|
+
<div class="form-row">
|
|
227
|
+
<label for="node-config-input-connectionTimeout"><i class="fa fa-clock-o"></i> Connection Timeout</label>
|
|
228
|
+
<input type="number" id="node-config-input-connectionTimeout" placeholder="3" style="width: 80px;"/>
|
|
229
|
+
<span style="margin-left: 5px;">seconds</span>
|
|
230
|
+
</div>
|
|
231
|
+
<div class="form-row">
|
|
232
|
+
<label for="node-config-input-loginTimeout"><i class="fa fa-clock-o"></i> Login Timeout</label>
|
|
233
|
+
<input type="number" id="node-config-input-loginTimeout" placeholder="3" style="width: 80px;" />
|
|
234
|
+
<span style="margin-left: 5px;">seconds</span>
|
|
235
|
+
</div>
|
|
102
236
|
</div>
|
|
103
|
-
|
|
104
|
-
<div class="form-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
237
|
+
|
|
238
|
+
<div class="form-section-header expanded"><h4><i class="fa fa-caret-right"></i> <i class="fa fa-exclamation-triangle"></i> Error Handling & Retry</h4></div>
|
|
239
|
+
<div class="form-section-content">
|
|
240
|
+
<div class="form-row">
|
|
241
|
+
<label for="node-config-input-retryFreshConnection" style="width: auto;"><i class="fa fa-refresh"></i> Retry with fresh connection</label>
|
|
242
|
+
<input type="checkbox" id="node-config-input-retryFreshConnection" style="display: inline-block; width: auto; vertical-align: top;" />
|
|
243
|
+
</div>
|
|
244
|
+
<div class="retry-options" style="padding-left: 20px;">
|
|
245
|
+
<div class="form-row">
|
|
246
|
+
<label for="node-config-input-retryDelay"><i class="fa fa-history"></i> Retry Delay</label>
|
|
247
|
+
<input type="number" id="node-config-input-retryDelay" placeholder="5" style="width: 80px;" />
|
|
248
|
+
<span style="margin-left: 5px;">seconds</span>
|
|
249
|
+
</div>
|
|
250
|
+
<div class="form-row">
|
|
251
|
+
<label for="node-config-input-retryOnMsg" style="width: auto;"><i class="fa fa-envelope-o"></i> Retry on new message</label>
|
|
252
|
+
<input type="checkbox" id="node-config-input-retryOnMsg" style="display: inline-block; width: auto; vertical-align: top;" />
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
113
255
|
</div>
|
|
114
256
|
|
|
115
|
-
<div class="form-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
/>
|
|
136
|
-
</div>
|
|
137
|
-
|
|
138
|
-
<div class="form-row input-syntax">
|
|
139
|
-
<label for="node-config-input-syntax"
|
|
140
|
-
><i class="fa fa-language"></i> Syntax</label
|
|
141
|
-
>
|
|
142
|
-
<select id="node-config-input-syntax" style="width: 70%">
|
|
143
|
-
<option value="bigquery">BigQuery</option>
|
|
144
|
-
<option value="db2">DB2</option>
|
|
145
|
-
<option value="hive">Hive</option>
|
|
146
|
-
<option value="mariadb">MariaDB</option>
|
|
147
|
-
<option value="mysql">Mysql</option>
|
|
148
|
-
<option value="postgresql">PostgresQL</option>
|
|
149
|
-
<option value="sqlite">Sqlite</option>
|
|
150
|
-
<option value="transactsql">TransactSQL</option>
|
|
151
|
-
<option value="flinksql">FlinkSQL</option>
|
|
152
|
-
</select>
|
|
257
|
+
<div class="form-section-header"><h4><i class="fa fa-caret-right"></i> <i class="fa fa-wrench"></i> Advanced</h4></div>
|
|
258
|
+
<div class="form-section-content" style="display: none;">
|
|
259
|
+
<div class="form-row">
|
|
260
|
+
<label for="node-config-input-syntaxtick" style="width: auto;"><i class="fa fa-check-square-o"></i> Syntax Checker</label>
|
|
261
|
+
<input type="checkbox" id="node-config-input-syntaxtick" style="display: inline-block; width: auto; vertical-align: top;" />
|
|
262
|
+
</div>
|
|
263
|
+
<div class="form-row input-syntax">
|
|
264
|
+
<label for="node-config-input-syntax"><i class="fa fa-language"></i> Syntax</label>
|
|
265
|
+
<select id="node-config-input-syntax" style="width: 70%">
|
|
266
|
+
<option value="bigquery">BigQuery</option>
|
|
267
|
+
<option value="db2">DB2</option>
|
|
268
|
+
<option value="hive">Hive</option>
|
|
269
|
+
<option value="mariadb">MariaDB</option>
|
|
270
|
+
<option value="mysql">Mysql</option>
|
|
271
|
+
<option value="postgresql">PostgresQL</option>
|
|
272
|
+
<option value="sqlite">Sqlite</option>
|
|
273
|
+
<option value="transactsql">TransactSQL</option>
|
|
274
|
+
<option value="flinksql">FlinkSQL</option>
|
|
275
|
+
</select>
|
|
276
|
+
</div>
|
|
153
277
|
</div>
|
|
154
278
|
</script>
|
|
155
279
|
|
|
280
|
+
|
|
156
281
|
<script type="text/javascript">
|
|
157
282
|
RED.nodes.registerType("odbc", {
|
|
158
|
-
category: "storage",
|
|
283
|
+
category: "storage-input",
|
|
159
284
|
color: "#89A5C0",
|
|
160
285
|
defaults: {
|
|
161
286
|
name: { value: "" },
|
|
162
287
|
connection: { type: "odbc config", required: true },
|
|
163
288
|
query: { value: "" },
|
|
164
289
|
outputObj: { value: "payload" },
|
|
290
|
+
streaming: { value: false },
|
|
291
|
+
streamChunkSize: { value: 1, validate: RED.validators.number() }
|
|
165
292
|
},
|
|
166
293
|
inputs: 1,
|
|
167
294
|
outputs: 1,
|
|
@@ -175,6 +302,10 @@
|
|
|
175
302
|
mode: "ace/mode/sql",
|
|
176
303
|
value: this.query,
|
|
177
304
|
});
|
|
305
|
+
|
|
306
|
+
$("#node-input-streaming").on("change", function() {
|
|
307
|
+
$(".stream-options").toggle(this.checked);
|
|
308
|
+
}).trigger("change");
|
|
178
309
|
},
|
|
179
310
|
oneditsave: function () {
|
|
180
311
|
this.query = this.editor.getValue();
|
|
@@ -193,156 +324,26 @@
|
|
|
193
324
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
194
325
|
<input type="text" id="node-input-name" />
|
|
195
326
|
</div>
|
|
196
|
-
|
|
197
327
|
<div class="form-row">
|
|
198
|
-
<label for="node-input-connection"
|
|
199
|
-
><i class="fa fa-cog"></i> Connection</label
|
|
200
|
-
>
|
|
328
|
+
<label for="node-input-connection"><i class="fa fa-cog"></i> Connection</label>
|
|
201
329
|
<input type="text" id="node-input-connection" />
|
|
202
330
|
</div>
|
|
203
|
-
|
|
204
331
|
<div class="form-row node-text-editor-row">
|
|
205
|
-
<label for="node-input-query" style="width: 100% !important;"
|
|
206
|
-
|
|
207
|
-
>
|
|
208
|
-
<div
|
|
209
|
-
style="height: 250px;"
|
|
210
|
-
class="node-text-editor"
|
|
211
|
-
id="node-input-query-editor"
|
|
212
|
-
></div>
|
|
332
|
+
<label for="node-input-query" style="width: 100% !important;"><i class="fa fa-search"></i> Query</label>
|
|
333
|
+
<div style="height: 250px;" class="node-text-editor" id="node-input-query-editor"></div>
|
|
213
334
|
</div>
|
|
214
|
-
|
|
215
335
|
<div class="form-row">
|
|
216
|
-
<label for="node-input-outputObj"
|
|
217
|
-
|
|
218
|
-
>
|
|
219
|
-
<span>msg.</span
|
|
220
|
-
><input
|
|
221
|
-
type="text"
|
|
222
|
-
id="node-input-outputObj"
|
|
223
|
-
placeholder="payload"
|
|
224
|
-
style="width: 64%;"
|
|
225
|
-
/>
|
|
336
|
+
<label for="node-input-outputObj"><i class="fa fa-edit"></i> Result to</label>
|
|
337
|
+
<span>msg.</span><input type="text" id="node-input-outputObj" placeholder="payload" style="width: 64%;"/>
|
|
226
338
|
</div>
|
|
227
|
-
|
|
228
|
-
<
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
Check your ODBC driver documentation for more information about valid connection strings.
|
|
239
|
-
|
|
240
|
-
Example:
|
|
241
|
-
|
|
242
|
-
```
|
|
243
|
-
DSN=MyDSN;DFT=2;
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
- (optional) **`initialSize`**: <`number`>
|
|
247
|
-
|
|
248
|
-
The number of connections created in the pool when it is initialized. Default: 5.
|
|
249
|
-
|
|
250
|
-
- (optional) **`incrementSize`**: <`number`>
|
|
251
|
-
|
|
252
|
-
The number of connections that are created when the pool is exhausted. Default: 5.
|
|
253
|
-
|
|
254
|
-
- (optional) **`maxSize`**: <`number`>
|
|
255
|
-
|
|
256
|
-
The maximum number of connections allowed in the pool before it won't create any more. Default: 15.
|
|
257
|
-
|
|
258
|
-
- (optional) **`shrinkPool`**: <`boolean`>
|
|
259
|
-
|
|
260
|
-
Whether the number of connections should be reduced to `initialSize` when they are returned to the pool. Default: true.
|
|
261
|
-
|
|
262
|
-
- (optional) **`connectionTimeout`**: <`number`>
|
|
263
|
-
|
|
264
|
-
The number of seconds for a connection to remain idle before closing. Default: 3.
|
|
265
|
-
|
|
266
|
-
- (optional) **`loginTimeout`**: <`number`>
|
|
267
|
-
|
|
268
|
-
The number of seconds for an attempt to create a connection before returning to the application. Default: 3.
|
|
269
|
-
|
|
270
|
-
- (optional) **`retryFreshConnection`**: <`boolean`> If checked, in case of a query error, the node will attempt the query a second time using a brand new database connection instead of one from the pool. If this second attempt is successful, it indicates the pooled connection was faulty, and the entire connection pool will be reset. Default: false.
|
|
271
|
-
|
|
272
|
-
- (optional) **`syntaxChecker`**: <`boolean`>
|
|
273
|
-
|
|
274
|
-
Whether the syntax validator is activated or not. If activated, the query string will be
|
|
275
|
-
[parsed](https://www.npmjs.com/package/node-sql-parser#create-ast-for-sql-statement)
|
|
276
|
-
and appended as an object to the output message with a key named `parsedQuery`. Default: false.
|
|
277
|
-
|
|
278
|
-
- (optional) **`syntax`**: <`string`>
|
|
279
|
-
|
|
280
|
-
Dropdown list of the available [SQL flavors available](https://www.npmjs.com/package/node-sql-parser#supported-database-sql-syntax).
|
|
281
|
-
Default: mysql.
|
|
282
|
-
</script>
|
|
283
|
-
|
|
284
|
-
<script type="text/markdown" data-help-name="odbc">
|
|
285
|
-
A node that runs a query when input is received. Each instance of the node can define its own query string,
|
|
286
|
-
as well as take a query and/or parameters as input. A query sent as an input message will override any query
|
|
287
|
-
defined in the node properties.
|
|
288
|
-
|
|
289
|
-
## Properties
|
|
290
|
-
|
|
291
|
-
- (**required**) **`connection`**: <`odbc config`>
|
|
292
|
-
|
|
293
|
-
The ODBC pool node that defines the connection settings and manages the connection pool used by this node.
|
|
294
|
-
|
|
295
|
-
- (optional) **`query`**: <`string`>
|
|
296
|
-
|
|
297
|
-
A valid SQL query string.
|
|
298
|
-
|
|
299
|
-
- Can contain parameters inserted using Mustache syntax (e.g., `{{{payload}}}`).
|
|
300
|
-
- Can use placeholders (`?`) for parameters.
|
|
301
|
-
- Can embed parameters directly in the query string.
|
|
302
|
-
|
|
303
|
-
- (**required**) **`result to`**: <`dot-notation string`>
|
|
304
|
-
|
|
305
|
-
The JSON nested element structure that will contain the result output. The string must be a valid
|
|
306
|
-
JSON object structure using dot-notation, minus the `msg.` (e.g., `payload.results`) and must not
|
|
307
|
-
start or end with a period. Square bracket notation is not allowed. The node input object is carried
|
|
308
|
-
out to the output, as long as the output object name does not conflict with it. If the targeted output
|
|
309
|
-
JSON object was already present in the input, the result from the query will be appended to it if it
|
|
310
|
-
was itself an object (but not an array); otherwise, the original key/value pair will be overwritten.
|
|
311
|
-
|
|
312
|
-
Example:
|
|
313
|
-
|
|
314
|
-
- `input msg: {"payload": {"result": {"othervalue": 10} } };`
|
|
315
|
-
- `result to: payload.results.values`
|
|
316
|
-
|
|
317
|
-
In this case, `values` will be appended to `result` without overwriting `othervalue`.
|
|
318
|
-
If `result` had been a string, then it would have been replaced by `values`.
|
|
319
|
-
|
|
320
|
-
## Inputs
|
|
321
|
-
|
|
322
|
-
The `odbc` node accepts a message input that can contain:
|
|
323
|
-
|
|
324
|
-
- **`query`**: <`string`> A valid SQL query string. This overrides the query defined in the node properties.
|
|
325
|
-
- **`payload`**:
|
|
326
|
-
- A JSON string containing a `query` property with the SQL string.
|
|
327
|
-
- An object with a `query` property containing the SQL string.
|
|
328
|
-
- **`parameters`**: <`array` or `object`>
|
|
329
|
-
- Can be an array of values corresponding to the placeholders (`?`) in the query.
|
|
330
|
-
- Can be an object mapping parameter names to values. If the query contains placeholders (`?`) and `msg.parameters` is an object, the values will be automatically mapped to the placeholders based on the order of the parameters in the query.
|
|
331
|
-
|
|
332
|
-
## Outputs
|
|
333
|
-
|
|
334
|
-
Returns a message containing:
|
|
335
|
-
|
|
336
|
-
- **`output object`**: <`array`> The `odbc` result array returned from the query.
|
|
337
|
-
- **`odbc`**: <`object`> Contains additional information returned by the `odbc` module.
|
|
338
|
-
- **`parsedQuery`**: <`object`> (Optional) The parsed SQL query if the syntax checker is enabled.
|
|
339
|
-
|
|
340
|
-
## Automatic Prepared Statement Handling
|
|
341
|
-
|
|
342
|
-
The node automatically determines whether to use a prepared statement or a regular query based on the following:
|
|
343
|
-
|
|
344
|
-
- **Presence of Placeholders:** If the query string contains placeholders (`?`), the node will use a prepared statement.
|
|
345
|
-
- **`msg.parameters` Object/Array:** If the `msg.parameters` object/array is provided, the node will use a prepared statement.
|
|
346
|
-
|
|
347
|
-
This automatic handling ensures that your queries are executed in the most secure way possible, minimizing the risk of SQL injection vulnerabilities.
|
|
348
|
-
</script>
|
|
339
|
+
<hr/>
|
|
340
|
+
<div class="form-row">
|
|
341
|
+
<label for="node-input-streaming" style="width: auto;"><i class="fa fa-arrows-v"></i> Stream Results</label>
|
|
342
|
+
<input type="checkbox" id="node-input-streaming" style="display: inline-block; width: auto; vertical-align: top;">
|
|
343
|
+
</div>
|
|
344
|
+
<div class="form-row stream-options">
|
|
345
|
+
<label for="node-input-streamChunkSize"><i class="fa fa-bars"></i> Chunk Size</label>
|
|
346
|
+
<input type="number" id="node-input-streamChunkSize" placeholder="1" style="width: 100px;">
|
|
347
|
+
<span class="form-tips">Number of rows per output message.</span>
|
|
348
|
+
</div>
|
|
349
|
+
</script>
|