Skip to content

Instantly share code, notes, and snippets.

@dac09
Created February 28, 2014 00:26
Show Gist options
  • Save dac09/9262691 to your computer and use it in GitHub Desktop.
Save dac09/9262691 to your computer and use it in GitHub Desktop.
Node mysql table create and insert example
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'mysql'
});
connection.connect();
connection.query('CREATE TABLE test.table1(Col1 VARCHAR(10), Col2 VARCHAR(50))', function(err, rows, fields) {
// connection.query('INSERT INTO test.table1 VALUES("blahblah", "blahblah2")', function(err, rows, fields) {
if (err) throw err;
// console.log('The solution is: ', rows[0].solution);
});
connection.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment