当前位置:网站首页>Using nodejs to operate MySQL
Using nodejs to operate MySQL
2022-07-28 22:34:00 【Crane sorrow_】
One , Use of modules
1. Install the module
npm i axios -S
2. The import module
var axios = require('axios');
3. Using modules
axios.get(url)
.then(res=>res.data)
.catch(err=>err)
Two , Custom module
1. A file is a module
Define modules
module.exports = {
max:function(a,b){return a}
min:(a,b)=>b
}
2. The import module
const utils = require("./utils")
utils.max(15,20)
3. Using modules
var {max,min} =require("./utils.js")
min(5,20)
3、 ... and 、fs Document processing
1. Import file module
var fs = require('fs')
2. Read
var re = fs.readyFileSync(url,"utf-8")
fs.readyFile(url,"utf-8",function(err,data){})
3. write in
fs.writeFileSync(url,data)
fs.writeFile(url,data,function(err){})
Four 、http The server
1. Import
var http = require("http");
var url = require("url")// Address resolution
2. Create a server
var server = http.createServer(function(req,res){
var Url = url.parse(req.url);// analysis url
res.status = 200;// Set status code
res.setHeader("Content-Type","application/json")
res.end(`{}`}
})
3. Listen and start
server.listen("8888",function(){
console.log(" The server is up ")
})
5、 ... and 、mysql install
1. Configure environment variables
C:\Program Files\MySQL\MySQL Server 5.7\bin
2. initialization
mysqld -install
mysqld --initialize
3. Start the server
net start mysql
4. Sign in
mysql -u root -p
6、 ... and ,mysql command
1. Inquire about
select * from user where 1
2. Querying a user
select * from user where name='zeng8' and password='zmm123'
3. The score is greater than 500
select * from user where score>500
4. Query all users , from 1 Began to intercept 2 strip
select * from user where 1 limit 1,2
5. Query all users , Sort by score , Ascending acs Descending desc
select * from user where 1 order by score asc
边栏推荐
- Alibaba cloud CDN practice
- JS array merging, de duplication, dimensionality reduction (es6: extended operator, set)
- [Ruiji takeout] day05 package management business development
- 近期bug总结
- tutorial/detailed_workflow.ipynb 量化金融Qlib库
- [CS231N]Lecture_2:Image Classification pipelin
- Sword finger offer II 066. sum of words (medium prefix tree design string)
- Necessary for in-depth learning: split the data set, split the labels according to the split pictures, and check the interval of all marked labels
- Analysis notes on let (const) temporary dead zone in JS
- HCIP(12)
猜你喜欢
随机推荐
96. Different binary search trees (medium binary search tree dynamic planning)
Solve Jupiter: the term 'Jupiter' is not recognized as the name of a cmdlet, function, script file
98. Verify binary search tree (medium binary search tree DFS)
PaddleNLP基于ERNIR3.0文本分类:WOS数据集为例(层次分类)
NPM switch Taobao source (NPM source)
Excel-VBA 快速上手(十三、日期的常见用法)
Wechat applet uses canvas drawing, round avatar, network background, text, dotted line, straight line
tutorial/detailed_ workflow. Ipynb quantitative finance qlib Library
LCR测试仪最为主要的功能和用途都是什么
lotus 1.16.0 延长扇区过期时间
HCIP(15)
Sword finger offer II 064. magic Dictionary (medium dictionary tree string design)
Sword finger offer II 057. the difference between the value and the subscript is within the given range (medium array bucket sort sliding window TreeSet)
How to install WiFi correctly
PaddleNLP基于ERNIR3.0文本分类以CAIL2018-SMALL数据集罪名预测任务为例【多标签】
SSH password free login
Att & CK preliminary understanding
Sword finger offer II 067. maximum XOR (medium prefix tree bit operation array)
ngx+sql环境离线安装日志(rpm安装)
Use REM to make the font size adaptive to the screen








![[LiteratureReview]Object Detection and Mapping with Bounding Box Constraints](/img/37/7cb5fa3a9078a5f5947485147c819d.png)
