How to Run Synchronous Queries using sync-sql Module in Node.js ? Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report 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 the 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. node index.js Project Structure: Now open MySQL and create a database for example 'demo'. Filename: index.js javascript const Mysql = require('sync-mysql') const connection = new Mysql({ host:'localhost', user:'root', password:'password', database:'demo' }) let result = connection.query('SELECT NOW()') console.log(result) Steps to run the program: Make sure you install sync-sql using the following commands: npm install sync-sql Run the index.js file using the below command: node index.js Output: So this is how you can run synchronized SQL queries in node js using sync-sql package. Comment More infoAdvertise with us Next Article How to Run Synchronous Queries using sync-sql Module in Node.js ? G gouravhammad Follow Improve Article Tags : JavaScript Web Technologies Node.js Write From Home Node.js-Misc +1 More Similar Reads How to Make a Synchronous MongoDB Query in NodeJS? MongoDB is a popular NoSQL database that is often used in modern web development. It is known for its flexibility, scalability, and ease of use. Node.js, with its non-blocking, event-driven architecture, is a natural fit for MongoDB. However, working with asynchronous code can sometimes be challengi 2 min read How to Use MongoDB Transactions in Node.js? Using MongoDB transactions in Node.js involves several steps. Transactions allow multiple operations on the database to be executed in an all-or-nothing manner, ensuring data consistency. we will learn how to use MongoDB transaction in Node.js.PrerequisitesMongoDB (Version 4.0 or higher Recommended) 2 min read How to Perform a findOne Operation in MongoDB using Node.js? The findOne operation in MongoDB is used to get a single document from the collection if the given query matches the collection record. While using findOne, if more than one record is there with the exact same match, then it will return the very first one. We will use this operation if we need to fe 4 min read How to Use Prepared Statements in MySQL with Node.js MySQL prepared a database by pre-compiling the SQL query with a set of placeholders for parameters. You could use the MySQL2 or MySQL library to be connected to your MySQL database and execute queries by passing the SQL statement with an array of values for the placeholders. It prevents SQL injectio 9 min read How to update data in sqlite3 using Node.js ? In this article, we are going to see how to update data in the sqlite3 database using node.js. So for this, we are going to use the run function which is available in sqlite3. This function will help us to run the queries for updating the data.SQLite is a self-contained, high-reliability, embedded, 4 min read Like