You can find the following code snippet in the Express documentation.

var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', user : 'dbuser', password : 's3kreee7' }); connection.connect(); connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) { if (err) throw err; console.log('The solution is: ', rows[0].solution); }); connection.end(); 

Please tell us how safe this approach is (from injection and load in real projects) and how it should be stored in the root of the server folder. It is better to always break into modules (by MVC) and by files, and how to come to this?

  • And where does the verification of the connection connection with the database with MVC? All that is done here is connecting to the database, calculating the test query and closing the connection without using any parameters. - Daniel Protopopov
  • 2

0