SQL in the MySQL statement
Classification in SQL statements:
---DDL: (data define language) to define the columns (create,drop,alter,truncate)
---DML: (data manipulate language)-operation data row (insert Delete,update)
---DQL: (data Query Language)--querying (SELECT)
---DCL: (Data Control Language)--controlling user rights (Grant,revoke)
Using node. js to access the MySQL server requires the use of a third-party module--mysql module
1.---Create a connection to the database server
Const MySQL = require (' mysql ');
var con = mysql.createconnertion ({});
---Send SQL statements to the database server for execution
Con.query (' sql ... ', function (Err,result) {});
---close connection con.end ();
2.--Creating a connection pool
Const MySQL = require (' mysql ');
var pool = Mysql.createpool ({
Host: ' localhost ',
User: ' Root ',
Password: ",
Connectionlimit:10});
Pool.getconnection ((Err,con) =>{
Con.query (' sql:?,? [ x, Y], (err,result) =>{
Con.release ();
}}
node. JS (Connection MySQL)