mysql-ssh icon indicating copy to clipboard operation
mysql-ssh copied to clipboard

Close connection

Open Wooody82 opened this issue 6 years ago • 0 comments

Hi, How could I close connection if i want to use some kind of db wrapper

const mysqlssh = require('mysql-ssh');
//const fs = require('fs');

var sqlConnect =  mysqlssh.connect(
					{
						host: '192.168.33.10',
						user: 'vagrant',
						password: 'vagrant',
					},
					{
						host: '127.0.0.1',
						user: 'root',
						password: 'root',
						database: 'testing'
					}
				)
				.catch(err => {
					console.log(err)
				})				

module.exports = sqlConnect;

I tried to import on the other file... and tried to close connection but did not work var sqlConnect = require('./db.js'); var mysqlssh = require('mysql-ssh');

 sql.then( client => {
                    client.query("INSERT INTO tasks set ?", newTask, function (err, res) {
                        if(err) {
                            console.log("error: ", err);
                            result(err, null);
                        }
                        else{
                            console.log(res.insertId);
                            result(null, res.insertId);
                        }
                    }); 
                }     
            )         
            .catch(err => {
                console.log(err)
            })            

Wooody82 avatar Dec 25 '19 21:12 Wooody82