zoukankan      html  css  js  c++  java
  • node.js(连接mysql)

           mysql语句中的SQL

        sql语句中的分类:

     ---DDL:(data define language)定义数据列(create,drop,alter,truncate)

     ---DML:(data manipulate language)--操作数据行(insert delete,update)

     ---DQL:(data query language)--数据查询(select)

     ---DCL:(data control language)--控制用户权限(grant,revoke)

    使用node.js访问mysql服务器,需要使用第三方模块--mysql模块

    1.  ---创建到数据库服务器的连接

               const mysql = require('mysql');

                var con = mysql.createConnertion({});

         ---发送SQL语句给数据库服务器来执行

               con.query('sql...',function(err,result){});

         ---关闭连接 con.end();

    2.--创建连接池

              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();

                      }}

       

               

  • 相关阅读:
    Codeforces 1009F Dominant Indices
    UOJ #35 后缀排序 哈希做法
    bzoj 3670 [Noi2014]动物园
    动态规划 笔记

    常用模块和面向对象 类
    常用模块
    包的使用和常用模块
    日志
    复习列表,模块
  • 原文地址:https://www.cnblogs.com/xuzhudong/p/6804826.html
Copyright © 2011-2022 走看看