当前位置:网站首页>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
边栏推荐
- SQL注入 Less34(POST型宽字节注入+布尔盲注)
- SSH password free login
- (翻译)图技术简明历史
- Ngx+sql environment offline installation log (RPM installation)
- Soft exam network engineer
- MySQL installation and configuration (super detailed, simple and practical)
- Hcip experiment (15)
- HCIP(14)
- 纪念一下第一次写的线段树了喽(对应洛谷3372)
- 76. Minimum coverage substring (hard sliding window hash table string)
猜你喜欢

ATT&CK 威胁情报
![[LiteratureReview]Object Detection and Mapping with Bounding Box Constraints](/img/37/7cb5fa3a9078a5f5947485147c819d.png)
[LiteratureReview]Object Detection and Mapping with Bounding Box Constraints

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

Establishment of Ruiji takeout development environment

微信小程序剪切图片的功能

Static details of static members
![[CS231N]Lecture_2:Image Classification pipelin](/img/4f/de56b071560ada746c587a9dbc5f02.jpg)
[CS231N]Lecture_2:Image Classification pipelin

SQL injection less42 (post stack injection)

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

CDN working principle
随机推荐
NPM switch Taobao source (NPM source)
JS convert numbers to letters
mysql create语句能不能用来建立表结构并追加新的记录
[LiteratureReview]Object Detection and Mapping with Bounding Box Constraints
Jianzhi offer II 062. implement prefix tree (medium design dictionary tree prefix tree string)
Common commands of NPM
6K6w5LiA5qyh5pS75Ye75YiG5p6Q
Ukrainian officials: half of Ukrainian agricultural products are exported through the Danube port
There will be a black line on the border when the button in the wechat applet is clicked
lotus 1.16.0 延长扇区过期时间
Ruiji takeout - background login function development
Win11 how to open software notification
Sword finger offer II 066. sum of words (medium prefix tree design string)
Remember the first line segment tree (corresponding to Luogu 3372)
gprs网络指的是什么
Static route and default route experiment
JS array merging, de duplication, dimensionality reduction (es6: extended operator, set)
[Ruiji takeout project] Day5 - Chapter 6 mobile verification code login
Winserver operation and maintenance technology stack
纪念一下第一次写的线段树了喽(对应洛谷3372)