O'Reilly logo

The Node Craftsman Book by Manuel Kiessling

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the Streaming API

Next, we will query some real data from existing tables. For this, we first need to create a database, add a table to it, and insert some rows. Let's do this through a Node.js application. Please create a file create.js with the following content:

 'use strict'; var mysql = require('mysql'); var connection = mysql.createConnection({ host: 'localhost', user: 'root', password: 'root' }); connection.query('CREATE DATABASE node', function(err) { if (err) { console.log('Could not create database "node".'); } }); connection.query('USE node', function(err) { if (err) { console.log('Could not switch to database "node".'); } }); connection.query('CREATE TABLE test ' + '(id INT(11) AUTO_INCREMENT, ' + ' content VARCHAR(255), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required