1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00
node-red-nodes/storage/mysql/68-mysql.html
Dave Conway-Jones fea47843d7
Change mysql library to mysql2 as it is more maintained and support latest mysql authention (#862)
* Use mysql2 lib

* fix pool on acquire event cause MaxListenersExceededWarning (#854)

before: every query need to register pool on acquire event to specify queryFormat based on payload type
will cause MaxListenersExceededWarning

after:
from https://www.npmjs.com/package/mysql#pooling-connections

pool.query is a shortcut for pool.getConnection() -> connection.query() -> connection.release()

so use pool.getConnection and then
set queryFormat before query method be called

Co-authored-by: Dave Conway-Jones <dceejay@users.noreply.github.com>

* fix mysql require

* Add decimalNumbers flag true to mysql beta

* mysql remove old Timeout option, clarify timezone options

* add mysqlConnectionLimit settings option.

Co-authored-by: saknarak <saknarak@gmail.com>
2022-01-05 10:56:14 +00:00

90 lines
3.6 KiB
HTML

<script type="text/html" data-template-name="MySQLdatabase">
<div class="form-row">
<label for="node-config-input-host"><i class="fa fa-globe"></i> <span data-i18n="mysql.label.host"></span></label>
<input type="text" id="node-config-input-host">
</div>
<div class="form-row">
<label for="node-config-input-port"><i class="fa fa-random"></i> <span data-i18n="mysql.label.port"></span></label>
<input type="text" id="node-config-input-port">
</div>
<div class="form-row">
<label for="node-config-input-user"><i class="fa fa-user"></i> <span data-i18n="mysql.label.user"></span></label>
<input type="text" id="node-config-input-user">
</div>
<div class="form-row">
<label for="node-config-input-pass"><i class="fa fa-lock"></i> <span data-i18n="mysql.label.password"></label>
<input type="password" id="node-config-input-password">
</div>
<div class="form-row">
<label for="node-config-input-db"><i class="fa fa-database"></i> <span data-i18n="mysql.label.database"></span></label>
<input type="text" id="node-config-input-db">
</div>
<div class="form-row">
<label for="node-config-input-tz"><i class="fa fa-clock-o"></i> <span data-i18n="mysql.label.timezone"></span></label>
<input type="text" id="node-config-input-tz" placeholder="&#177;hh:mm">
</div>
<div class="form-row">
<label for="node-config-input-charset"><i class="fa fa-language"></i> <span data-i18n="mysql.label.charset"></span></label>
<input type="text" id="node-config-input-charset">
</div>
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-config-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-tips"><span data-i18n="[html]mysql.tip"></span></div>
</script>
<script type="text/javascript">
RED.nodes.registerType('MySQLdatabase',{
category: 'config',
defaults: {
name: {value:""},
host: {value:"127.0.0.1",required:true},
port: {value:"3306",required:true},
db: {value:"",required:true},
tz: {value:""},
charset: {value:"UTF8"}
},
credentials: {
user: {type: "text"},
password: {type: "password"}
},
label: function() {
return this.name || this.db;
}
});
</script>
<script type="text/html" data-template-name="mysql">
<div class="form-row">
<label for="node-input-mydb"><i class="fa fa-database"></i> <span data-i18n="mysql.label.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> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('mysql',{
category: 'storage-input',
color:"#e97b00",
defaults: {
mydb: {type:"MySQLdatabase",required:true},
name: {value:""}
},
inputs:1,
outputs:1,
icon: "db.png",
label: function() {
var levelNode = RED.nodes.node(this.mydb);
return this.name||(levelNode?levelNode.label():"mysql");
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>