Skip to content

Instantly share code, notes, and snippets.

@divanvisagie
Created February 26, 2013 06:51
Show Gist options
  • Save divanvisagie/5036510 to your computer and use it in GitHub Desktop.
Save divanvisagie/5036510 to your computer and use it in GitHub Desktop.
MySql database connection template for node.js
var mysql = require( 'mysql' );
var connection_details = {
host : 'localhost',
user : 'root',
password : 'password',
database : 'databasename'
};
exports.DBManager = function (){ /* open a database connection */
this.open = function(){
this.connection = mysql.createConnection( connection_details );
this.connection.connect();
};
this.close = function(){
this.connection.end();
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment