当前位置:网站首页>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
边栏推荐
- 成立不到一年!MIT衍生量子计算公司完成900万美元融资
- 使用webWorker执行后台任务
- [binary tree] pseudo palindrome path in binary tree
- Ultra detailed visual studio 2019 running littlevgl (lvgl) simulator
- 删除容器镜像报错解决image is referenced in multiple repositories
- Summary of common error types in JS
- redis相关
- Solve the problem that TS node xxx.ts executes TS code and reports errors
- Leetcode question brushing series - sum of majority type
- Sword finger offer II 053. Medium order successor in binary search tree (medium binary search tree DFS)
猜你喜欢

Which is the file transfer command in the basic services of the Internet

Mysql内置函数

Idea generate class diagram plug-in UML (super detailed)

Win11 how to open software notification

Sword finger offer II 053. Medium order successor in binary search tree (medium binary search tree DFS)

Alibaba cloud CDN practice

Ngrok intranet penetration

Can the MySQL create statement be used to create a table structure and append new records

CDN working principle

When can I sign up for the 2022 class I constructor examination?
随机推荐
Leetcode question brushing series - sum of majority type
Sword finger offer II 063. replacement word (medium prefix tree string)
Summary of the use of hash table set and map when leetcode brushes questions
HCIP(11)
[Ruiji takeout project]day4 - dish management
lotus 1.16.0 延长扇区过期时间
What are the main functions and uses of LCR tester
Hcip experiment (12)
静态路由和缺省路由实验
Lotus 1.16.0 extend sector expiration time
ssh免密登陆
[LiteratureReview]Object Detection and Mapping with Bounding Box Constraints
[LiteratureReview]Object Detection and Mapping with Bounding Box Constraints
Wechat applet uses canvas drawing, round avatar, network background, text, dotted line, straight line
Jianzhi offer II 062. implement prefix tree (medium design dictionary tree prefix tree string)
Mysql8.0 cannot authorize users or prompt you are not allowed to create a user with grant
SQL注入 Less34(POST型宽字节注入+布尔盲注)
【转载】token令牌在登录场景使用
SQL injection less42 (post stack injection)
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