@aaqu/fromcubes-db 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/NOTICE +24 -0
- package/README.md +442 -2
- package/SECURITY.md +75 -0
- package/THIRD-PARTY-NOTICES.md +151 -0
- package/examples/Quick Start/All Databases.json +1719 -0
- package/examples/Quick Start/ClickHouse.json +278 -0
- package/examples/Quick Start/CockroachDB.json +280 -0
- package/examples/Quick Start/Firebird.json +278 -0
- package/examples/Quick Start/MariaDB.json +281 -0
- package/examples/Quick Start/MySQL.json +281 -0
- package/examples/Quick Start/Oracle.json +280 -0
- package/examples/Quick Start/PostgreSQL.json +280 -0
- package/examples/Quick Start/SQL Server.json +282 -0
- package/examples/Quick Start/SQLite.json +278 -0
- package/examples/Quick Start/TiDB.json +281 -0
- package/examples/Quick Start/YugabyteDB.json +280 -0
- package/examples/SQLite Sensor Log With Portal.json +391 -0
- package/examples/Select With Parameters.json +130 -0
- package/index.js +32 -0
- package/lib/adapters/clickhouse.js +254 -0
- package/lib/adapters/firebird.js +416 -0
- package/lib/adapters/index.js +37 -0
- package/lib/adapters/mssql.js +178 -0
- package/lib/adapters/mysql.js +171 -0
- package/lib/adapters/oracle.js +272 -0
- package/lib/adapters/postgres.js +161 -0
- package/lib/adapters/read.js +57 -0
- package/lib/adapters/sqlite.js +193 -0
- package/lib/adapters/time.js +89 -0
- package/lib/bound.js +29 -0
- package/lib/editor-api.js +134 -0
- package/lib/editor-preview.js +191 -0
- package/lib/errors.js +66 -0
- package/lib/params.js +966 -0
- package/lib/pool.js +391 -0
- package/lib/settings.js +302 -0
- package/lib/sql/compile.js +160 -0
- package/lib/sql/dialect.js +194 -0
- package/lib/sql/parse.js +202 -0
- package/lib/sql/types.js +1071 -0
- package/lib/sqlite-files.js +137 -0
- package/nodes/connection.html +728 -0
- package/nodes/connection.js +179 -0
- package/nodes/editor/ark-pixel.LICENSE.txt +96 -0
- package/nodes/editor/ark-pixel.woff2 +0 -0
- package/nodes/editor/mark.svg +5 -0
- package/nodes/editor/sql-editor.css +604 -0
- package/nodes/editor/sql-editor.js +1490 -0
- package/nodes/editor/sql-model.js +203 -0
- package/nodes/icons/fromcubes-db.svg +24 -0
- package/nodes/query.html +662 -0
- package/nodes/query.js +195 -0
- package/package.json +81 -4
|
@@ -0,0 +1,728 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
(function () {
|
|
3
|
+
/**
|
|
4
|
+
* The databases on offer come from the runtime — `lib/sql/dialect.js` is the
|
|
5
|
+
* only place a product is declared, and this dialog asks for the list rather
|
|
6
|
+
* than keeping a copy that could drift from it.
|
|
7
|
+
*
|
|
8
|
+
* Two products can share one engine (MariaDB on mysql, CockroachDB on
|
|
9
|
+
* postgres) and still be separate choices here: separate labels, separate
|
|
10
|
+
* ports, separate saved values. The field blocks below are keyed by engine,
|
|
11
|
+
* which is why `engineOf` exists.
|
|
12
|
+
*/
|
|
13
|
+
const PRODUCTS = [];
|
|
14
|
+
const ENGINE_OF = {};
|
|
15
|
+
const DEFAULT_PORTS = {};
|
|
16
|
+
|
|
17
|
+
// The query node reads this to write the database name above its nodes.
|
|
18
|
+
const DIALECT_LABELS = {};
|
|
19
|
+
|
|
20
|
+
function engineOf(product) {
|
|
21
|
+
return ENGINE_OF[product] || product;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function absorb(list) {
|
|
25
|
+
PRODUCTS.length = 0;
|
|
26
|
+
for (const p of list) {
|
|
27
|
+
PRODUCTS.push(p);
|
|
28
|
+
ENGINE_OF[p.id] = p.engine;
|
|
29
|
+
DIALECT_LABELS[p.id] = p.label;
|
|
30
|
+
if (p.defaultPort) DEFAULT_PORTS[p.id] = p.defaultPort;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const loaded = $.getJSON("fromcubes-db/products")
|
|
35
|
+
.then(absorb)
|
|
36
|
+
.catch(function () {
|
|
37
|
+
/* No list means the picker falls back to whatever the node already has;
|
|
38
|
+
an editor that cannot reach its own runtime has bigger problems. */
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/** Fills the picker, keeping whatever the node is set to. */
|
|
42
|
+
function fillPicker(selected) {
|
|
43
|
+
const select = $("#node-config-input-dialect");
|
|
44
|
+
if (PRODUCTS.length === 0) {
|
|
45
|
+
// Never leave the user with an empty picker: keep what they saved.
|
|
46
|
+
if (selected && select.find("option").length === 0) {
|
|
47
|
+
select.append($("<option/>").val(selected).text(selected));
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
select.empty();
|
|
51
|
+
for (const p of PRODUCTS) {
|
|
52
|
+
select.append($("<option/>").val(p.id).text(p.label));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (selected) select.val(selected);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* SQLite is a file, and Oracle in descriptor mode carries host, port and
|
|
60
|
+
* service in one string — neither shows the host/port/database fields.
|
|
61
|
+
*/
|
|
62
|
+
function usesHostFields(node) {
|
|
63
|
+
if (node.dialect === "sqlite") return false;
|
|
64
|
+
return !(node.dialect === "oracle" && node.oraMode === "descriptor");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
RED.nodes.registerType("fromcubes-db-connection", {
|
|
68
|
+
category: "config",
|
|
69
|
+
// Filled from the runtime's product list. The query node reads it through
|
|
70
|
+
// RED.nodes.getType to write the database name above its nodes, rather
|
|
71
|
+
// than holding a second copy that could drift.
|
|
72
|
+
dialectLabels: DIALECT_LABELS,
|
|
73
|
+
defaults: {
|
|
74
|
+
name: { value: "" },
|
|
75
|
+
dialect: { value: "postgres", required: true },
|
|
76
|
+
showDialect: { value: true },
|
|
77
|
+
host: {
|
|
78
|
+
value: "localhost",
|
|
79
|
+
validate: function (v) {
|
|
80
|
+
return !usesHostFields(this) || (v || "").trim() !== "";
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
port: { value: 5432, validate: RED.validators.number(true) },
|
|
84
|
+
database: {
|
|
85
|
+
value: "",
|
|
86
|
+
validate: function (v) {
|
|
87
|
+
return !usesHostFields(this) || (v || "").trim() !== "";
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
// Where the login comes from. 'cred' is the stored credential, which is
|
|
92
|
+
// what every flow saved before these fields existed has; 'env' names an
|
|
93
|
+
// environment variable, for an image built before the device it runs on
|
|
94
|
+
// has a password. The name is a normal property — only the secret is a
|
|
95
|
+
// credential, and a variable name is not a secret.
|
|
96
|
+
userSource: { value: "cred" },
|
|
97
|
+
userEnv: {
|
|
98
|
+
value: "",
|
|
99
|
+
validate: function (v) {
|
|
100
|
+
return this.userSource !== "env" || (v || "").trim() !== "";
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
passwordSource: { value: "cred" },
|
|
104
|
+
passwordEnv: {
|
|
105
|
+
value: "",
|
|
106
|
+
validate: function (v) {
|
|
107
|
+
return this.passwordSource !== "env" || (v || "").trim() !== "";
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
// pool and timeouts
|
|
112
|
+
poolMin: { value: 0, validate: RED.validators.number(true) },
|
|
113
|
+
poolMax: { value: 10, validate: RED.validators.number(true) },
|
|
114
|
+
idleTimeoutMs: { value: 30000, validate: RED.validators.number(true) },
|
|
115
|
+
connectTimeoutMs: { value: 15000, validate: RED.validators.number(true) },
|
|
116
|
+
queryTimeoutMs: { value: 30000, validate: RED.validators.number(true) },
|
|
117
|
+
queueMax: { value: 100, validate: RED.validators.number(true) },
|
|
118
|
+
undefinedAsNull: { value: false },
|
|
119
|
+
|
|
120
|
+
// PostgreSQL
|
|
121
|
+
pgSsl: { value: "disable" },
|
|
122
|
+
pgCa: { value: "" },
|
|
123
|
+
pgSchema: { value: "" },
|
|
124
|
+
|
|
125
|
+
// MySQL / MariaDB
|
|
126
|
+
mySsl: { value: false },
|
|
127
|
+
mySslVerify: { value: true },
|
|
128
|
+
myCharset: { value: "" },
|
|
129
|
+
myTimezone: { value: "" },
|
|
130
|
+
|
|
131
|
+
// SQL Server
|
|
132
|
+
msEncrypt: { value: true },
|
|
133
|
+
msTrustCert: { value: false },
|
|
134
|
+
msInstance: { value: "" },
|
|
135
|
+
msDomain: { value: "" },
|
|
136
|
+
|
|
137
|
+
// SQLite
|
|
138
|
+
sqliteFile: {
|
|
139
|
+
value: "",
|
|
140
|
+
// A plain name, mirroring lib/sqlite-files.js: the file lives in
|
|
141
|
+
// <userDir>/fromcubes-db and a path is refused there anyway.
|
|
142
|
+
validate: function (v) {
|
|
143
|
+
if (this.dialect !== "sqlite") return true;
|
|
144
|
+
const name = (v || "").trim();
|
|
145
|
+
if (name === ":memory:") return true;
|
|
146
|
+
return (
|
|
147
|
+
/^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,98}[A-Za-z0-9])?$/.test(name) &&
|
|
148
|
+
name.indexOf("..") === -1 &&
|
|
149
|
+
!/^(?:con|prn|aux|nul|com\d|lpt\d)(?:\.|$)/i.test(name)
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
sqliteReadOnly: { value: false },
|
|
154
|
+
sqliteWal: { value: true },
|
|
155
|
+
sqliteForeignKeys: { value: true },
|
|
156
|
+
sqliteBusyTimeoutMs: { value: 5000, validate: RED.validators.number(true) },
|
|
157
|
+
|
|
158
|
+
// Oracle
|
|
159
|
+
oraMode: { value: "easy" },
|
|
160
|
+
oraConnectString: {
|
|
161
|
+
value: "",
|
|
162
|
+
validate: function (v) {
|
|
163
|
+
return this.dialect !== "oracle" || this.oraMode !== "descriptor" || (v || "").trim() !== "";
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
oraIdentifier: { value: "service" },
|
|
167
|
+
|
|
168
|
+
// Firebird
|
|
169
|
+
fbRole: { value: "" },
|
|
170
|
+
|
|
171
|
+
// ClickHouse
|
|
172
|
+
chTls: { value: false },
|
|
173
|
+
|
|
174
|
+
// shared by PostgreSQL and SQL Server
|
|
175
|
+
appName: { value: "" },
|
|
176
|
+
|
|
177
|
+
options: {
|
|
178
|
+
value: "",
|
|
179
|
+
validate: function (v) {
|
|
180
|
+
if (!v || v.trim() === "") return true;
|
|
181
|
+
try {
|
|
182
|
+
JSON.parse(v);
|
|
183
|
+
return true;
|
|
184
|
+
} catch (e) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
credentials: {
|
|
191
|
+
user: { type: "text" },
|
|
192
|
+
password: { type: "password" },
|
|
193
|
+
},
|
|
194
|
+
label: function () {
|
|
195
|
+
if (this.name) return this.name;
|
|
196
|
+
if (this.dialect === "sqlite") return "sqlite:" + (this.sqliteFile || "?");
|
|
197
|
+
if (this.dialect === "oracle" && this.oraMode === "descriptor") {
|
|
198
|
+
return "oracle://" + (this.oraConnectString || "?");
|
|
199
|
+
}
|
|
200
|
+
const db = this.database ? "/" + this.database : "";
|
|
201
|
+
return (this.dialect || "db") + "://" + (this.host || "?") + db;
|
|
202
|
+
},
|
|
203
|
+
oneditprepare: function () {
|
|
204
|
+
const node = this;
|
|
205
|
+
|
|
206
|
+
// SQLite: offer the databases already in <userDir>/fromcubes-db and say
|
|
207
|
+
// where the one typed will live. Typing a new name creates it.
|
|
208
|
+
let sqliteDir = "";
|
|
209
|
+
function showSqliteTarget() {
|
|
210
|
+
const name = ($("#node-config-input-sqliteFile").val() || "").trim();
|
|
211
|
+
let text = "";
|
|
212
|
+
if (name === ":memory:") text = "In memory — gone on every redeploy and restart.";
|
|
213
|
+
else if (name && sqliteDir) {
|
|
214
|
+
const file = /\.(db|sqlite|sqlite3)$/i.test(name) ? name : name + ".db";
|
|
215
|
+
text = sqliteDir + "/" + file;
|
|
216
|
+
} else if (sqliteDir) text = "Databases live in " + sqliteDir;
|
|
217
|
+
$("#fromcubes-db-sqlite-target").text(text);
|
|
218
|
+
}
|
|
219
|
+
$.getJSON("fromcubes-db/sqlite/databases")
|
|
220
|
+
.done(function (list) {
|
|
221
|
+
sqliteDir = list.directory || "";
|
|
222
|
+
const options = $("#fromcubes-db-sqlite-list").empty();
|
|
223
|
+
(list.databases || []).forEach(function (db) {
|
|
224
|
+
const kb = Math.max(1, Math.round(db.size / 1024));
|
|
225
|
+
options.append($("<option/>", { value: db.name }).text(db.file + " — " + kb + " KB"));
|
|
226
|
+
});
|
|
227
|
+
showSqliteTarget();
|
|
228
|
+
})
|
|
229
|
+
.fail(showSqliteTarget);
|
|
230
|
+
$("#node-config-input-sqliteFile").on("input change", showSqliteTarget);
|
|
231
|
+
|
|
232
|
+
fillPicker(node.dialect);
|
|
233
|
+
// The list may still be in flight on the first dialog after a reload.
|
|
234
|
+
loaded.then(function () {
|
|
235
|
+
fillPicker($("#node-config-input-dialect").val() || node.dialect);
|
|
236
|
+
refresh();
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
function refresh() {
|
|
240
|
+
const dialect = $("#node-config-input-dialect").val();
|
|
241
|
+
const engine = engineOf(dialect);
|
|
242
|
+
|
|
243
|
+
// Only the selected engine's block is shown, so the dialog lists what
|
|
244
|
+
// this database actually accepts and nothing else. Products sharing an
|
|
245
|
+
// engine share its fields until one of them declares its own.
|
|
246
|
+
$("[data-dialect]").each(function () {
|
|
247
|
+
$(this).toggle($(this).attr("data-dialect") === engine);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
const file = engine === "sqlite";
|
|
251
|
+
const descriptor = engine === "oracle" && $("#node-config-input-oraMode").val() === "descriptor";
|
|
252
|
+
$("#fromcubes-db-host-fields").toggle(!descriptor && !file);
|
|
253
|
+
$("#fromcubes-db-descriptor-fields").toggle(descriptor);
|
|
254
|
+
// A local file has no login.
|
|
255
|
+
$("#fromcubes-db-credentials").toggle(!file);
|
|
256
|
+
// Each of the two logins shows either its value or the name of the
|
|
257
|
+
// environment variable it is read from, never both.
|
|
258
|
+
const userEnv = $("#node-config-input-userSource").val() === "env";
|
|
259
|
+
const passwordEnv = $("#node-config-input-passwordSource").val() === "env";
|
|
260
|
+
$("#fromcubes-db-user-value").toggle(!userEnv);
|
|
261
|
+
$("#fromcubes-db-user-env").toggle(userEnv);
|
|
262
|
+
$("#fromcubes-db-password-value").toggle(!passwordEnv);
|
|
263
|
+
$("#fromcubes-db-password-env").toggle(passwordEnv);
|
|
264
|
+
$("#fromcubes-db-env-tip").toggle(userEnv || passwordEnv);
|
|
265
|
+
$("#fromcubes-db-my-verify").toggle($("#node-config-input-mySsl").is(":checked"));
|
|
266
|
+
|
|
267
|
+
$("#fromcubes-db-database-label").text(
|
|
268
|
+
engine === "oracle"
|
|
269
|
+
? $("#node-config-input-oraIdentifier").val() === "sid"
|
|
270
|
+
? "SID"
|
|
271
|
+
: "Service name"
|
|
272
|
+
: "Database",
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
$("#fromcubes-db-pg-ca").toggle($("#node-config-input-pgSsl").val() !== "disable");
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
$("#node-config-input-dialect").on("change", function () {
|
|
279
|
+
const dialect = $(this).val();
|
|
280
|
+
const port = $("#node-config-input-port");
|
|
281
|
+
// Only replace a port the user has not deliberately changed.
|
|
282
|
+
if (
|
|
283
|
+
DEFAULT_PORTS[dialect] &&
|
|
284
|
+
(!port.val() || Object.values(DEFAULT_PORTS).indexOf(Number(port.val())) !== -1)
|
|
285
|
+
) {
|
|
286
|
+
port.val(DEFAULT_PORTS[dialect]);
|
|
287
|
+
}
|
|
288
|
+
refresh();
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
$("#node-config-input-userSource").on("change", refresh);
|
|
292
|
+
$("#node-config-input-passwordSource").on("change", refresh);
|
|
293
|
+
$("#node-config-input-oraMode").on("change", refresh);
|
|
294
|
+
$("#node-config-input-oraIdentifier").on("change", refresh);
|
|
295
|
+
$("#node-config-input-pgSsl").on("change", refresh);
|
|
296
|
+
$("#node-config-input-mySsl").on("change", refresh);
|
|
297
|
+
|
|
298
|
+
refresh();
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
})();
|
|
302
|
+
</script>
|
|
303
|
+
|
|
304
|
+
<script type="text/html" data-template-name="fromcubes-db-connection">
|
|
305
|
+
<div class="form-row">
|
|
306
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
307
|
+
<input type="text" id="node-config-input-name" placeholder="optional" />
|
|
308
|
+
</div>
|
|
309
|
+
<div class="form-row">
|
|
310
|
+
<label for="node-config-input-dialect"><i class="fa fa-database"></i> Database</label>
|
|
311
|
+
<!-- Filled from GET fromcubes-db/products; see the script above. -->
|
|
312
|
+
<select id="node-config-input-dialect"></select>
|
|
313
|
+
</div>
|
|
314
|
+
<div class="form-row">
|
|
315
|
+
<label for="node-config-input-showDialect"> </label>
|
|
316
|
+
<input type="checkbox" id="node-config-input-showDialect" style="width: auto; vertical-align: top" />
|
|
317
|
+
<span>Write the database name above query nodes using this connection</span>
|
|
318
|
+
</div>
|
|
319
|
+
|
|
320
|
+
<div id="fromcubes-db-host-fields">
|
|
321
|
+
<div class="form-row">
|
|
322
|
+
<label for="node-config-input-host"><i class="fa fa-server"></i> Host</label>
|
|
323
|
+
<input type="text" id="node-config-input-host" placeholder="localhost" />
|
|
324
|
+
</div>
|
|
325
|
+
<div class="form-row">
|
|
326
|
+
<label for="node-config-input-port"><i class="fa fa-plug"></i> Port</label>
|
|
327
|
+
<input type="text" id="node-config-input-port" style="width: 100px" />
|
|
328
|
+
</div>
|
|
329
|
+
<div class="form-row">
|
|
330
|
+
<label for="node-config-input-database" id="fromcubes-db-database-label">Database</label>
|
|
331
|
+
<input type="text" id="node-config-input-database" />
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
|
|
335
|
+
<div id="fromcubes-db-descriptor-fields" style="display: none">
|
|
336
|
+
<div class="form-row">
|
|
337
|
+
<label for="node-config-input-oraConnectString">Connect string</label>
|
|
338
|
+
<input type="text" id="node-config-input-oraConnectString" placeholder="host:1521/FREEPDB1" />
|
|
339
|
+
</div>
|
|
340
|
+
<div class="form-row">
|
|
341
|
+
<label> </label>
|
|
342
|
+
<span class="form-tips" style="display: inline-block; max-width: 70%">
|
|
343
|
+
Easy Connect, a full TNS descriptor, or an alias from <code>tnsnames.ora</code>.
|
|
344
|
+
</span>
|
|
345
|
+
</div>
|
|
346
|
+
</div>
|
|
347
|
+
|
|
348
|
+
<div id="fromcubes-db-credentials">
|
|
349
|
+
<div class="form-row">
|
|
350
|
+
<label for="node-config-input-userSource"><i class="fa fa-user"></i> User</label>
|
|
351
|
+
<select id="node-config-input-userSource" style="width: 200px">
|
|
352
|
+
<option value="cred">value</option>
|
|
353
|
+
<option value="env">environment variable</option>
|
|
354
|
+
</select>
|
|
355
|
+
</div>
|
|
356
|
+
<div class="form-row" id="fromcubes-db-user-value">
|
|
357
|
+
<label for="node-config-input-user"> </label>
|
|
358
|
+
<input type="text" id="node-config-input-user" />
|
|
359
|
+
</div>
|
|
360
|
+
<div class="form-row" id="fromcubes-db-user-env" style="display: none">
|
|
361
|
+
<label for="node-config-input-userEnv"> </label>
|
|
362
|
+
<input type="text" id="node-config-input-userEnv" placeholder="POSTGRES_USER" />
|
|
363
|
+
</div>
|
|
364
|
+
|
|
365
|
+
<div class="form-row">
|
|
366
|
+
<label for="node-config-input-passwordSource"><i class="fa fa-lock"></i> Password</label>
|
|
367
|
+
<select id="node-config-input-passwordSource" style="width: 200px">
|
|
368
|
+
<option value="cred">value</option>
|
|
369
|
+
<option value="env">environment variable</option>
|
|
370
|
+
</select>
|
|
371
|
+
</div>
|
|
372
|
+
<div class="form-row" id="fromcubes-db-password-value">
|
|
373
|
+
<label for="node-config-input-password"> </label>
|
|
374
|
+
<input type="password" id="node-config-input-password" />
|
|
375
|
+
</div>
|
|
376
|
+
<div class="form-row" id="fromcubes-db-password-env" style="display: none">
|
|
377
|
+
<label for="node-config-input-passwordEnv"> </label>
|
|
378
|
+
<input type="text" id="node-config-input-passwordEnv" placeholder="POSTGRES_PASSWORD" />
|
|
379
|
+
</div>
|
|
380
|
+
<div class="form-row" id="fromcubes-db-env-tip" style="display: none">
|
|
381
|
+
<label> </label>
|
|
382
|
+
<span class="form-tips" style="display: inline-block; max-width: 70%">
|
|
383
|
+
The name of a variable, not its value — read when the node starts, so the flow can ship before the password
|
|
384
|
+
exists. Unset at start means the connection does not open.
|
|
385
|
+
</span>
|
|
386
|
+
</div>
|
|
387
|
+
</div>
|
|
388
|
+
|
|
389
|
+
<!-- PostgreSQL -->
|
|
390
|
+
<div data-dialect="postgres">
|
|
391
|
+
<hr />
|
|
392
|
+
<div class="form-row">
|
|
393
|
+
<label for="node-config-input-pgSsl">SSL</label>
|
|
394
|
+
<select id="node-config-input-pgSsl">
|
|
395
|
+
<option value="disable">off</option>
|
|
396
|
+
<option value="require">require (no certificate check)</option>
|
|
397
|
+
<option value="verify-ca">verify CA</option>
|
|
398
|
+
<option value="verify-full">verify CA and hostname</option>
|
|
399
|
+
</select>
|
|
400
|
+
</div>
|
|
401
|
+
<div class="form-row" id="fromcubes-db-pg-ca" style="display: none">
|
|
402
|
+
<label for="node-config-input-pgCa">CA certificate</label>
|
|
403
|
+
<input type="text" id="node-config-input-pgCa" placeholder="PEM contents, optional" />
|
|
404
|
+
</div>
|
|
405
|
+
<div class="form-row">
|
|
406
|
+
<label for="node-config-input-pgSchema">Schema</label>
|
|
407
|
+
<input type="text" id="node-config-input-pgSchema" placeholder="public" />
|
|
408
|
+
</div>
|
|
409
|
+
</div>
|
|
410
|
+
|
|
411
|
+
<!-- MySQL / MariaDB -->
|
|
412
|
+
<div data-dialect="mysql" style="display: none">
|
|
413
|
+
<hr />
|
|
414
|
+
<div class="form-row">
|
|
415
|
+
<label for="node-config-input-mySsl"> </label>
|
|
416
|
+
<input type="checkbox" id="node-config-input-mySsl" style="width: auto; vertical-align: top" />
|
|
417
|
+
<span>Use SSL</span>
|
|
418
|
+
</div>
|
|
419
|
+
<div class="form-row" id="fromcubes-db-my-verify" style="display: none">
|
|
420
|
+
<label for="node-config-input-mySslVerify"> </label>
|
|
421
|
+
<input type="checkbox" id="node-config-input-mySslVerify" style="width: auto; vertical-align: top" />
|
|
422
|
+
<span>Verify the server certificate</span>
|
|
423
|
+
</div>
|
|
424
|
+
<div class="form-row">
|
|
425
|
+
<label for="node-config-input-myCharset">Charset</label>
|
|
426
|
+
<input type="text" id="node-config-input-myCharset" placeholder="utf8mb4" style="width: 160px" />
|
|
427
|
+
</div>
|
|
428
|
+
<div class="form-row">
|
|
429
|
+
<label for="node-config-input-myTimezone">Timezone</label>
|
|
430
|
+
<input type="text" id="node-config-input-myTimezone" placeholder="Z (UTC)" style="width: 160px" />
|
|
431
|
+
</div>
|
|
432
|
+
</div>
|
|
433
|
+
|
|
434
|
+
<!-- SQL Server -->
|
|
435
|
+
<div data-dialect="mssql" style="display: none">
|
|
436
|
+
<hr />
|
|
437
|
+
<div class="form-row">
|
|
438
|
+
<label for="node-config-input-msEncrypt"> </label>
|
|
439
|
+
<input type="checkbox" id="node-config-input-msEncrypt" style="width: auto; vertical-align: top" />
|
|
440
|
+
<span>Encrypt the connection</span>
|
|
441
|
+
</div>
|
|
442
|
+
<div class="form-row">
|
|
443
|
+
<label for="node-config-input-msTrustCert"> </label>
|
|
444
|
+
<input type="checkbox" id="node-config-input-msTrustCert" style="width: auto; vertical-align: top" />
|
|
445
|
+
<span>Trust the server certificate (needed for self-signed ones)</span>
|
|
446
|
+
</div>
|
|
447
|
+
<div class="form-row">
|
|
448
|
+
<label for="node-config-input-msInstance">Instance</label>
|
|
449
|
+
<input type="text" id="node-config-input-msInstance" placeholder="SQLEXPRESS" style="width: 200px" />
|
|
450
|
+
</div>
|
|
451
|
+
<div class="form-row">
|
|
452
|
+
<label for="node-config-input-msDomain">Domain</label>
|
|
453
|
+
<input type="text" id="node-config-input-msDomain" placeholder="NTLM domain, optional" style="width: 200px" />
|
|
454
|
+
</div>
|
|
455
|
+
</div>
|
|
456
|
+
|
|
457
|
+
<!-- Oracle -->
|
|
458
|
+
<div data-dialect="oracle" style="display: none">
|
|
459
|
+
<hr />
|
|
460
|
+
<div class="form-row">
|
|
461
|
+
<label for="node-config-input-oraMode">Connect using</label>
|
|
462
|
+
<select id="node-config-input-oraMode">
|
|
463
|
+
<option value="easy">host, port and service name</option>
|
|
464
|
+
<option value="descriptor">full connect string / TNS alias</option>
|
|
465
|
+
</select>
|
|
466
|
+
</div>
|
|
467
|
+
<div class="form-row">
|
|
468
|
+
<label for="node-config-input-oraIdentifier">Identifier is</label>
|
|
469
|
+
<select id="node-config-input-oraIdentifier">
|
|
470
|
+
<option value="service">service name</option>
|
|
471
|
+
<option value="sid">SID</option>
|
|
472
|
+
</select>
|
|
473
|
+
</div>
|
|
474
|
+
<div class="form-row">
|
|
475
|
+
<label> </label>
|
|
476
|
+
<span class="form-tips" style="display: inline-block; max-width: 70%">
|
|
477
|
+
Thin mode — no Oracle Instant Client needed.
|
|
478
|
+
</span>
|
|
479
|
+
</div>
|
|
480
|
+
</div>
|
|
481
|
+
|
|
482
|
+
<!-- Firebird -->
|
|
483
|
+
<div data-dialect="firebird" style="display: none">
|
|
484
|
+
<hr />
|
|
485
|
+
<div class="form-row">
|
|
486
|
+
<label for="node-config-input-fbRole">Role</label>
|
|
487
|
+
<input type="text" id="node-config-input-fbRole" placeholder="none" />
|
|
488
|
+
</div>
|
|
489
|
+
<div class="form-row">
|
|
490
|
+
<label> </label>
|
|
491
|
+
<span class="form-tips" style="display: inline-block; max-width: 70%">
|
|
492
|
+
Database is the path or alias on the server, e.g. <code>/var/lib/firebird/data/sensors.fdb</code> or an alias
|
|
493
|
+
from <code>databases.conf</code>. Firebird 4.0 or later.
|
|
494
|
+
</span>
|
|
495
|
+
</div>
|
|
496
|
+
</div>
|
|
497
|
+
|
|
498
|
+
<!-- ClickHouse -->
|
|
499
|
+
<div data-dialect="clickhouse" style="display: none">
|
|
500
|
+
<hr />
|
|
501
|
+
<div class="form-row">
|
|
502
|
+
<label for="node-config-input-chTls">HTTPS</label>
|
|
503
|
+
<input
|
|
504
|
+
type="checkbox"
|
|
505
|
+
id="node-config-input-chTls"
|
|
506
|
+
style="display: inline-block; width: auto; vertical-align: top"
|
|
507
|
+
/>
|
|
508
|
+
</div>
|
|
509
|
+
<div class="form-row">
|
|
510
|
+
<label> </label>
|
|
511
|
+
<span class="form-tips" style="display: inline-block; max-width: 70%">
|
|
512
|
+
HTTP interface (8123, or 8443 with HTTPS). No transactions, no UNIQUE or FOREIGN KEY constraints; UPDATE and
|
|
513
|
+
DELETE report no row count.
|
|
514
|
+
</span>
|
|
515
|
+
</div>
|
|
516
|
+
</div>
|
|
517
|
+
|
|
518
|
+
<!-- SQLite -->
|
|
519
|
+
<div data-dialect="sqlite" style="display: none">
|
|
520
|
+
<hr />
|
|
521
|
+
<div class="form-row">
|
|
522
|
+
<label for="node-config-input-sqliteFile"><i class="fa fa-database"></i> Database</label>
|
|
523
|
+
<input
|
|
524
|
+
type="text"
|
|
525
|
+
id="node-config-input-sqliteFile"
|
|
526
|
+
list="fromcubes-db-sqlite-list"
|
|
527
|
+
placeholder="sensors or :memory:"
|
|
528
|
+
autocomplete="off"
|
|
529
|
+
/>
|
|
530
|
+
<datalist id="fromcubes-db-sqlite-list"></datalist>
|
|
531
|
+
</div>
|
|
532
|
+
<div class="form-row">
|
|
533
|
+
<label> </label>
|
|
534
|
+
<span class="form-tips" id="fromcubes-db-sqlite-target" style="display: inline-block; max-width: 70%"></span>
|
|
535
|
+
</div>
|
|
536
|
+
<div class="form-row">
|
|
537
|
+
<label for="node-config-input-sqliteReadOnly"> </label>
|
|
538
|
+
<input type="checkbox" id="node-config-input-sqliteReadOnly" style="width: auto; vertical-align: top" />
|
|
539
|
+
<span>Read only</span>
|
|
540
|
+
</div>
|
|
541
|
+
<div class="form-row">
|
|
542
|
+
<label for="node-config-input-sqliteWal"> </label>
|
|
543
|
+
<input type="checkbox" id="node-config-input-sqliteWal" style="width: auto; vertical-align: top" />
|
|
544
|
+
<span>WAL journal (readers work while a writer holds the file)</span>
|
|
545
|
+
</div>
|
|
546
|
+
<div class="form-row">
|
|
547
|
+
<label for="node-config-input-sqliteForeignKeys"> </label>
|
|
548
|
+
<input type="checkbox" id="node-config-input-sqliteForeignKeys" style="width: auto; vertical-align: top" />
|
|
549
|
+
<span>Enforce foreign keys</span>
|
|
550
|
+
</div>
|
|
551
|
+
<div class="form-row">
|
|
552
|
+
<label for="node-config-input-sqliteBusyTimeoutMs">Busy timeout</label>
|
|
553
|
+
<input type="text" id="node-config-input-sqliteBusyTimeoutMs" style="width: 100px" /> ms
|
|
554
|
+
</div>
|
|
555
|
+
<div class="form-row">
|
|
556
|
+
<label> </label>
|
|
557
|
+
<span class="form-tips" style="display: inline-block; max-width: 70%">
|
|
558
|
+
Queries run synchronously, so a slow one blocks the whole Node-RED event loop.
|
|
559
|
+
</span>
|
|
560
|
+
</div>
|
|
561
|
+
</div>
|
|
562
|
+
|
|
563
|
+
<!-- shared -->
|
|
564
|
+
<div data-dialect="postgres">
|
|
565
|
+
<div class="form-row">
|
|
566
|
+
<label for="node-config-input-appName">Application name</label>
|
|
567
|
+
<input type="text" id="node-config-input-appName" placeholder="fromcubes-db" />
|
|
568
|
+
</div>
|
|
569
|
+
</div>
|
|
570
|
+
|
|
571
|
+
<hr />
|
|
572
|
+
<div class="form-row">
|
|
573
|
+
<label for="node-config-input-poolMin">Pool min / max</label>
|
|
574
|
+
<input type="text" id="node-config-input-poolMin" style="width: 60px" />
|
|
575
|
+
<input type="text" id="node-config-input-poolMax" style="width: 60px" />
|
|
576
|
+
</div>
|
|
577
|
+
<div class="form-row">
|
|
578
|
+
<label for="node-config-input-connectTimeoutMs">Connect timeout</label>
|
|
579
|
+
<input type="text" id="node-config-input-connectTimeoutMs" style="width: 100px" /> ms
|
|
580
|
+
</div>
|
|
581
|
+
<div class="form-row">
|
|
582
|
+
<label for="node-config-input-queryTimeoutMs">Query timeout</label>
|
|
583
|
+
<input type="text" id="node-config-input-queryTimeoutMs" style="width: 100px" /> ms
|
|
584
|
+
</div>
|
|
585
|
+
<div class="form-row">
|
|
586
|
+
<label for="node-config-input-idleTimeoutMs">Idle timeout</label>
|
|
587
|
+
<input type="text" id="node-config-input-idleTimeoutMs" style="width: 100px" /> ms
|
|
588
|
+
</div>
|
|
589
|
+
<div class="form-row">
|
|
590
|
+
<label for="node-config-input-queueMax">Queue limit</label>
|
|
591
|
+
<input type="text" id="node-config-input-queueMax" style="width: 100px" />
|
|
592
|
+
</div>
|
|
593
|
+
<div class="form-row">
|
|
594
|
+
<label for="node-config-input-undefinedAsNull"> </label>
|
|
595
|
+
<input type="checkbox" id="node-config-input-undefinedAsNull" style="width: auto; vertical-align: top" />
|
|
596
|
+
<span>Bind missing parameters as NULL instead of raising an error</span>
|
|
597
|
+
</div>
|
|
598
|
+
<div class="form-row">
|
|
599
|
+
<label for="node-config-input-options">Advanced</label>
|
|
600
|
+
<input type="text" id="node-config-input-options" placeholder='{"keepAlive":true}' />
|
|
601
|
+
</div>
|
|
602
|
+
</script>
|
|
603
|
+
|
|
604
|
+
<script type="text/html" data-help-name="fromcubes-db-connection">
|
|
605
|
+
<p>Connection pool shared by every query node that selects it.</p>
|
|
606
|
+
<p>
|
|
607
|
+
Pick the database first — the dialog then shows only the settings that database accepts. The pool opens on the first
|
|
608
|
+
query and closes when the last node using it is removed or redeployed, so a redeploy does not leave sessions behind
|
|
609
|
+
on the server.
|
|
610
|
+
</p>
|
|
611
|
+
<p>
|
|
612
|
+
Every database is listed on its own: <code>CockroachDB</code> and <code>YugabyteDB</code> are not filed under
|
|
613
|
+
PostgreSQL, and <code>MariaDB</code> and <code>TiDB</code> are not filed under MySQL. Some of them share a driver
|
|
614
|
+
today, which is a fact about today — picking the one you actually run means your flows already say so when that
|
|
615
|
+
changes. The field groups below are named after the driver they belong to, so two databases sharing one show up
|
|
616
|
+
together there.
|
|
617
|
+
</p>
|
|
618
|
+
<p>
|
|
619
|
+
The checkbox under the database picker writes the database name — <code>PostgreSQL</code>, <code>SQLite</code> — in
|
|
620
|
+
small type above every query node using this connection, so a node can show both its own name and the database it
|
|
621
|
+
runs against. Uncheck it and the query nodes look like any other.
|
|
622
|
+
</p>
|
|
623
|
+
|
|
624
|
+
<h3>PostgreSQL</h3>
|
|
625
|
+
<dl class="message-properties">
|
|
626
|
+
<dt>SSL</dt>
|
|
627
|
+
<dd>
|
|
628
|
+
<code>require</code> encrypts without checking the certificate; <code>verify-ca</code> and
|
|
629
|
+
<code>verify-full</code> check it, optionally against the CA you paste in.
|
|
630
|
+
</dd>
|
|
631
|
+
<dt>Schema</dt>
|
|
632
|
+
<dd>Sets <code>search_path</code> for every connection in the pool.</dd>
|
|
633
|
+
</dl>
|
|
634
|
+
|
|
635
|
+
<h3>MySQL / MariaDB</h3>
|
|
636
|
+
<dl class="message-properties">
|
|
637
|
+
<dt>Charset</dt>
|
|
638
|
+
<dd>Defaults to the server's. <code>utf8mb4</code> if you want full unicode.</dd>
|
|
639
|
+
<dt>Timezone</dt>
|
|
640
|
+
<dd>
|
|
641
|
+
The zone DATETIME and TIMESTAMP values are written and read in. Empty means <code>Z</code> — UTC, as on every
|
|
642
|
+
other database here, with the session's <code>time_zone</code> set to match. <code>+02:00</code> works the same
|
|
643
|
+
way with that offset; <code>local</code> uses Node-RED's own zone and leaves the session alone — only for tables
|
|
644
|
+
other programs already fill that way.
|
|
645
|
+
</dd>
|
|
646
|
+
</dl>
|
|
647
|
+
|
|
648
|
+
<h3>SQL Server</h3>
|
|
649
|
+
<dl class="message-properties">
|
|
650
|
+
<dt>Encrypt</dt>
|
|
651
|
+
<dd>On by default; SQL Server 2022 and Azure expect it.</dd>
|
|
652
|
+
<dt>Trust the server certificate</dt>
|
|
653
|
+
<dd>Needed for the self-signed certificate a local or container instance uses.</dd>
|
|
654
|
+
<dt>Instance</dt>
|
|
655
|
+
<dd>Named instance, e.g. <code>SQLEXPRESS</code>. Leave the port empty when using one.</dd>
|
|
656
|
+
<dt>Domain</dt>
|
|
657
|
+
<dd>Switches the login to NTLM with the user and password below.</dd>
|
|
658
|
+
</dl>
|
|
659
|
+
|
|
660
|
+
<h3>SQLite</h3>
|
|
661
|
+
<dl class="message-properties">
|
|
662
|
+
<dt>Database</dt>
|
|
663
|
+
<dd>
|
|
664
|
+
A name, not a path: <code>sensors</code> is <code><userDir>/fromcubes-db/sensors.db</code>. The folder and
|
|
665
|
+
the file are created on the first query if they are missing, and the field lists the databases already there.
|
|
666
|
+
Several connections can each name their own database. Letters, digits and <code>. _ -</code>;
|
|
667
|
+
<code>.sqlite</code>/<code>.sqlite3</code> are kept, anything else gets <code>.db</code>. <code>:memory:</code>
|
|
668
|
+
is a throwaway database. There is no host and no login.
|
|
669
|
+
</dd>
|
|
670
|
+
<dt>WAL journal</dt>
|
|
671
|
+
<dd>Lets readers work while a writer holds the file. Off for read-only databases.</dd>
|
|
672
|
+
<dt>Busy timeout</dt>
|
|
673
|
+
<dd>How long a writer waits for the lock before failing.</dd>
|
|
674
|
+
</dl>
|
|
675
|
+
<p>
|
|
676
|
+
Uses <code>node:sqlite</code>, built into Node itself, so nothing has to be compiled at install time. Queries are
|
|
677
|
+
synchronous: a slow one blocks the whole Node-RED event loop, which is fine for local data and wrong for a
|
|
678
|
+
multi-gigabyte table.
|
|
679
|
+
</p>
|
|
680
|
+
|
|
681
|
+
<h3>Oracle</h3>
|
|
682
|
+
<dl class="message-properties">
|
|
683
|
+
<dt>Connect using</dt>
|
|
684
|
+
<dd>
|
|
685
|
+
Host, port and service name for the common case; a full connect string or a
|
|
686
|
+
<code>tnsnames.ora</code> alias when the descriptor is more complex.
|
|
687
|
+
</dd>
|
|
688
|
+
<dt>Identifier is</dt>
|
|
689
|
+
<dd>Service name (<code>host:port/service</code>) or SID (<code>host:port:sid</code>).</dd>
|
|
690
|
+
</dl>
|
|
691
|
+
|
|
692
|
+
<h3>Pool</h3>
|
|
693
|
+
<dl class="message-properties">
|
|
694
|
+
<dt>Pool min / max</dt>
|
|
695
|
+
<dd>Connections kept open and the ceiling. Requests beyond the ceiling wait.</dd>
|
|
696
|
+
<dt>Queue limit</dt>
|
|
697
|
+
<dd>
|
|
698
|
+
How many queries may wait for a free connection. Beyond it they fail with QueueOverflowError instead of queueing
|
|
699
|
+
without bound, which keeps memory flat under overload. Applied by the node, so it means the same on every
|
|
700
|
+
database.
|
|
701
|
+
</dd>
|
|
702
|
+
<dt>Query timeout</dt>
|
|
703
|
+
<dd>
|
|
704
|
+
Covers the whole wait, including time spent queueing. Applied to the connection where the driver supports it, so a
|
|
705
|
+
per-node timeout can lower it but not raise it.
|
|
706
|
+
</dd>
|
|
707
|
+
<dt>Advanced</dt>
|
|
708
|
+
<dd>JSON merged into the driver configuration for anything no field covers. It wins over the fields above.</dd>
|
|
709
|
+
</dl>
|
|
710
|
+
|
|
711
|
+
<h3>User and password</h3>
|
|
712
|
+
<p>
|
|
713
|
+
Each of the two is either a <b>value</b> — stored encrypted, outside the flow file, so it never travels in an
|
|
714
|
+
exported flow — or the name of an <b>environment variable</b>, read when the node starts.
|
|
715
|
+
</p>
|
|
716
|
+
<p>
|
|
717
|
+
The variable is for a flow that is built before the login it will use exists: an image that ships to a device
|
|
718
|
+
provisioned with its own password, given to the container through <code>--env-file</code>. Set the source to
|
|
719
|
+
environment variable and type the <em>name</em>, e.g. <code>POSTGRES_PASSWORD</code> — the name is a normal setting,
|
|
720
|
+
only the value stays a secret, and the secret is then the device's, not the flow's.
|
|
721
|
+
</p>
|
|
722
|
+
<p>
|
|
723
|
+
Resolved the way every other environment reference in Node-RED is, so a variable set on the group or the flow is
|
|
724
|
+
found before the process one. If it is unset when the node starts, the node fails there: an error, a red status, and
|
|
725
|
+
no pool — rather than a connection that would fail on the first query with the server's own wording.
|
|
726
|
+
</p>
|
|
727
|
+
<p>The two are independent: a fixed user with the password from the environment is the usual pairing.</p>
|
|
728
|
+
</script>
|