Created
February 26, 2013 06:51
-
-
Save divanvisagie/5036510 to your computer and use it in GitHub Desktop.
MySql database connection template for node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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