The sync-sql module is designed to make synchronous queries to the database. Since normal SQL queries are asynchronous in node.js but if you want to run it synchronously, then it is possible using this module. In synchronized SQL, the result set is returned when the query is executed.
Note: Do not use this module in production mode as node.js is designed to be asynchronous.
Installation of sync-sql module:
- You can visit the link Install sync-sql module. You can install this package by using this command.
npm install sync-sql
- After installing sync-sql you can check your sync-sql version in command prompt using the command.
npm version sync-sql
- After that, you can just create a folder and add a file for example index.js, To run this file you need to run the following command.
- Now open MySQL and create a database for example ‘demo’.
Steps to run the program:
- The project structure will look like this:
- Make sure you install sync-sql using following commands:
npm install sync-sql
- Run index.js file using below command:
So this is how you can run synchronized SQL queries in node js using sync-sql package.
- Nodejs | Automatic restart NodeJs server with nodemon
- Nodejs | DNS
- Web-Socket in NodeJS
- Nodejs | Jimp
- Nodejs | DNS | setServers()
- Nodejs | GM segment() Function
- Nodejs | GM negative() Function
- Nodejs | GM orderedDither() Function
- Nodejs | GM roll() Function
- Nodejs | GM contrast() Function
- Nodejs | GM drawCircle() Function
- Nodejs | GM drawBezier() Function
- Nodejs | GM drawPolyline() Function
- Nodejs | GM drawLine() Function
- Nodejs | GM drawArc() Function
- Nodejs | GM motionBlur() Function
- Difference between NodeJS and AngularJS
- Nodejs | GM scale() Function
- Nodejs | GM paint() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.