I am a year into the front of the younger brother. I hope you can give me some comments or some code on other writing or ideas, etc. We just used Node.js to connect to mysql and we must have looked up the relevant data to give thisCopy the code
var connection = mysql.createConnection({ host : 'localhost', user : 'root', password : '123456', port: '3306', database: 'test' }); connection.connect(); var sql = 'SELECT * FROM websites'; Connection. query(SQL,function (err, result) {if(err){console.log('[SELECT ERROR] - ',err.message); return; } console.log('--------------------------SELECT----------------------------'); console.log(result); console.log('------------------------------------------------------------\n\n'); }); connection.end();Copy the code
First of all, there is no problem with your docking like this. This is also official. I also need to develop the front and back end of the development project, just contact node.js problems came out.
You’ll feel more comfortable with an interface and you’ll feel dead tired. Mysql > select * from ‘mysql’; mysql > select * from ‘mysql’; mysql > select * from ‘mysql’;
So HERE I provide a docking mysql writing method! Here at the back I hope to give you some help. At the same time, I hope you can give me some advice.
1. Provide access to all aspects of the project
Because it is convenient to change the mysql library address later, it is also convenient for you to hand over to others for operation and maintenance
2. Promise good encapsulation
3. How to use
Hope that the above can give you some help I put the picture in case of copy and paste lost regardless of ~ knock again it does not smell? Besides, it’s easy for the big guys to look at pictures. I was hoping you could give me some advice
Ask for praise and attention ~