Skip to content

Close connection #7

@Wooody82

Description

@Wooody82

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)
            })            

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions