const mariadb = require('mariadb'); const config = require('./config'); const pool = mariadb.createPool({ host: "test-db.verdnatura.es", database: "vn", user: config.userDev, password: config.passwordDev, port: 3307, connectionLimit: 5 }); pool.getConnection() .then(conn => { conn.query("SELECT 1 as val") .then(rows => { // rows: [ {val: 1}, meta: ... ] return conn.query("INSERT INTO smartTag value (?, ?)", [1, "mariadb"]); }) .then(res => { // res: { affectedRows: 1, insertId: 1, warningStatus: 0 } conn.release(); // release to pool }) .catch(err => { conn.release(); // release to pool }) }).catch(err => { //not connected });