当前位置:网站首页>Nodejs connect mysql
Nodejs connect mysql
2022-07-06 11:36:00 【Advanced diary】
install mysql drive
npm install mysqlConnect mysql database
// Import mysql drive const mysql = require("mysql"); // To configure mysql Connection information const con = mysql.createConnection({ host:"127.0.0.1",//ip Address user:" Database account ", password:" Database password ", port:"3306",// Port number database:"book"// The name of the database to connect to }) // Start connecting con.connect() // establish sql sentence const sql = "select * from users;" // perform sql sentence con.query(sql,(err,result)=>{ if(err){ console.error(err); return } console.log(result); }) // Close the connection con.end()Interested partners can learn together nodejs Knowledge compilation api Interface , You can see https://blog.csdn.net/qq_47824967/article/details/121909375?spm=1001.2014.3001.5501 How to write interfaces
边栏推荐
- When you open the browser, you will also open mango TV, Tiktok and other websites outside the home page
- Machine learning -- census data analysis
- Knowledge Q & A based on Apache Jena
- Wangeditor rich text reference and table usage
- Pytoch Foundation
- TypeScript
- vs2019 第一个MFC应用程序
- 02 staff information management after the actual project
- Integration test practice (1) theoretical basis
- Solve the problem of installing failed building wheel for pilot
猜你喜欢

AcWing 1298.曹冲养猪 题解

MySQL and C language connection (vs2019 version)

AcWing 242. A simple integer problem (tree array + difference)

Solve the problem of installing failed building wheel for pilot

QT creator test
![[yarn] yarn container log cleaning](/img/1d/b48059ae2e6133ea9d9c38d31c4a86.png)
[yarn] yarn container log cleaning

软件测试与质量学习笔记3--白盒测试
![[蓝桥杯2017初赛]方格分割](/img/e9/e49556d0867840148a60ff4906f78e.png)
[蓝桥杯2017初赛]方格分割

vs2019 使用向导生成一个MFC应用程序

In the era of DFI dividends, can TGP become a new benchmark for future DFI?
随机推荐
使用lambda在循环中传参时,参数总为同一个值
Database advanced learning notes -- SQL statement
分布式节点免密登录
Knowledge Q & A based on Apache Jena
[BSidesCF_2020]Had_a_bad_day
Neo4j installation tutorial
How to configure flymcu (STM32 serial port download software) is shown in super detail
[蓝桥杯2017初赛]方格分割
What does BSP mean
常用正则表达式整理
AI benchmark V5 ranking
What does usart1 mean
Kept VRRP script, preemptive delay, VIP unicast details
搞笑漫画:程序员的逻辑
Error reporting solution - io UnsupportedOperation: can‘t do nonzero end-relative seeks
Pytorch基础
02 staff information management after the actual project
Summary of numpy installation problems
ES6 Promise 对象
UDS learning notes on fault codes (0x19 and 0x14 services)