Using node.js with MySQL PRO

Developing a web application using the node.js framework we can easily write code that connects with a MySQL database. The mysql module provides us with everything we need. The following code sample shows how simple it is to use this module.

var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'server.zindell.com',
user: 'nodejsdemo',
password: 'lifemichael',
database: 'nodejsdemo',
port: 3306 });
connection.connect();
var query = connection.query('SELECT * FROM products',
	function(err, result, fields) 
	{
		if (err) throw err;
		console.log('result: ', result);
	});
connection.end();

The following video clip overviews this code sample, shows its execution and explains it.

You can find more video clips, code samples and various other training material for learning how to use node.js in my free online courses website at http://abelski.lifemichael.com.

Share:

The Visitor Design Pattern

The Visitor Design Pattern

The visitor design pattern allows us to add operations to objects that already exist without modifying their classes and without extending them.

What are Anti Patterns?

Anti Patterns

Unlike design patterns, anti patterns just seem to be a solution. However, they are not a solution and they cause additional costs.

Virtual Threads in Java Professional Seminar

Virtual Threads in Java

The use of virtual threads can assist us with improving the performance of our code. Learn how to use virtual threads effectively.

The Beauty of Code

Coding is Art! Developing Code That Works is Simple. Develop Code with Style is a Challenge!

Update cookies preferences