forked from node-red/node-red-nodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqlite.html
63 lines (57 loc) · 2.27 KB
/
sqlite.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<script type="text/x-red" data-template-name="sqlitedb">
<div class="form-row">
<label for="node-config-input-db"><i class="fa fa-database"></i> Database</label>
<input type="text" id="node-config-input-db" placeholder="/tmp/sqlite">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('sqlitedb',{
category: 'config',
defaults: {
db: {value:"",required:true}
},
label: function() {
return this.db;
}
});
</script>
<script type="text/x-red" data-template-name="sqlite">
<div class="form-row">
<label for="node-input-mydb"><i class="fa fa-database"></i> Database</label>
<input type="text" id="node-input-mydb">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="sqlite">
<p>Allows basic access to a Sqlite database.</p>
<p>This node uses the <b>db.all</b> operation against the configured database. This does allow INSERTS, UPDATES and DELETES.
By its very nature it is SQL injection... so <i>be careful out there...</i></p>
<p><code>msg.topic</code> must hold the <i>query</i> for the database, and the result is returned in <code>msg.payload</code>.</p>
<p><code>msg.payload</code> can contain an array of values to bind to the topic.</p>
<p>Typically the returned payload will be an array of the result rows, (or an error).</p>
<p>The reconnect timeout in milliseconds can be changed by adding a line to <b>settings.js</b>
<pre>sqliteReconnectTime: 20000,</pre></p>
</script>
<script type="text/javascript">
RED.nodes.registerType('sqlite',{
category: 'storage-input',
color:"#e97b00",
defaults: {
mydb: {type:"sqlitedb",required:true},
name: {value:""}
},
inputs:1,
outputs:1,
icon: "sqlite.png",
label: function() {
var dbNode = RED.nodes.node(this.mydb);
return this.name||(dbNode?dbNode.label():"sqlite");
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>