当前位置:网站首页>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
边栏推荐
- ES6 let and const commands
- AcWing 179. Factorial decomposition problem solution
- [CDH] modify the default port 7180 of cloudera manager in cdh/cdp environment
- 【presto】presto 参数配置优化
- Why can't STM32 download the program
- DICOM: Overview
- 常用正则表达式整理
- Aborted connection 1055898 to db:
- Vs2019 use wizard to generate an MFC Application
- [Flink] Flink learning
猜你喜欢

4、安装部署Spark(Spark on Yarn模式)

Integration test practice (1) theoretical basis

Wangeditor rich text reference and table usage

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

Learning question 1:127.0.0.1 refused our visit

About string immutability
![[蓝桥杯2017初赛]方格分割](/img/e9/e49556d0867840148a60ff4906f78e.png)
[蓝桥杯2017初赛]方格分割

QT creator support platform

MTCNN人脸检测
随机推荐
ES6 promise object
QT creator support platform
误删Path变量解决
[Presto] Presto parameter configuration optimization
In the era of DFI dividends, can TGP become a new benchmark for future DFI?
error C4996: ‘strcpy‘: This function or variable may be unsafe. Consider using strcpy_s instead
解决安装Failed building wheel for pillow
Database advanced learning notes -- SQL statement
Django running error: error loading mysqldb module solution
Are you monitored by the company for sending resumes and logging in to job search websites? Deeply convinced that the product of "behavior awareness system ba" has not been retrieved on the official w
vs2019 使用向导生成一个MFC应用程序
vs2019 桌面程序快速入门
L2-006 树的遍历 (25 分)
MySQL and C language connection (vs2019 version)
One click extraction of tables in PDF
Integration test practice (1) theoretical basis
jS数组+数组方法重构
2019腾讯暑期实习生正式笔试
Base de données Advanced Learning Notes - - SQL statements
Vs2019 desktop app quick start