Created
November 12, 2014 19:21
-
-
Save arbo77/d6457ac4936d2e3d63f2 to your computer and use it in GitHub Desktop.
NodeJS MySQL connection
This file contains hidden or 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 = mysql.createConnection( | |
| { | |
| host : 'localhost', | |
| user : 'root', | |
| password : '', | |
| database : 'apps', | |
| multipleStatements: true, | |
| } | |
| ); | |
| connection.connect(); | |
| var queryString = 'SELECT * FROM users'; | |
| connection.query(queryString, function(err, rows, fields) { | |
| if (err) throw err; | |
| for (var i in rows) { | |
| console.log(JSON.stringify(rows[i])); | |
| } | |
| }); | |
| connection.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment