Forbes India Leader Recognition
e.preventDefault(); // Prevent form submission input.blur(); // remove focus input.value = ""; // optional: clear the input

Implementing Cloud SQL Triggers Using Node.js

Implementing Cloud SQL Triggers Using Node.js

Featured Image

A relational database service for MySQL, PostgreSQL, and SQL Server is called Cloud SQL.

The vocabulary and fundamental ideas underlying Cloud SQL, which offers Google Cloud SQL data storage, are covered on this page. Cloud SQL feature supported by database engine for details on how different Cloud SQL databases stack up against one another.

The Node-API (formerly known as N-API) is an API for creating native Addons. It is maintained as a component of Node.js itself and is independent of the underlying JavaScript runtime (for instance, V8). This API will maintain its Application Binary Interface (ABI) stability across Node.js versions. It is designed to shield add-ons from modifications made to the JavaScript engine that powers the website and enable modules created for one major version of Node.js to function without the need for recompilation of major versions. An in-depth explanation is given in the ABI Stability Handbook.

To make sure that the app effectively connects to the Cloud SQL instance over a Unix socket made available to Cloud Functions, Cloud Run, and App Engine apps, we need to connect Cloud SQL with Node.js.

We are going to explore using the Node.js API to connect to the Cloud SQL database. We need the following for this:

  • Cloud SQL Database
  • Node API

Cloud SQL Database

In this section we will set up a database in Cloud SQL.

  • To begin, pick the Google project in the Google Console after it has opened.
  • Select SQL, followed by Create Instance, from the navigation menu in the top left. Hamburger Menu > SQL > Create Instance
  • Click on the MySQL database engine, enter the instance ID and password, and leave the rest of the information as it is.
  • After filling all the details click Create Instance.

Next we will connect to the instance using MySQL client in Cloud shell.

  • By selecting the Cloud shell icon in the upper left corner and selecting Continue, an open Cloud shell will appear.
  • Run the following command in the Cloud Shell prompt to establish a connection to your Cloud SQL instance:

gcloud sql connect –user=root

  • The instance connection name must then be obtained in order to access it in the Node API to connect to the SQL instance.
  • The Instance Connection Name can be found on the overview page of the SQL instance; copy it.
  • Click Databases on the overview page to create one by giving the database a name.
  • The instance ID can be choose from the overview page.
  • To create a User Account, select the Users tab. Right now, let any host in.
  • To add Network, select the Authorization tab. duplicate-paste IPV4.

Now we have a database, a user with a username and password, an instance, and we have whitelisted the IP address, we need to construct a table.

Node API

In this section, we’ll use the mysql module to connect to Cloud SQL.

  • Download and Install Node.js before installing mysql module.
  • Install mysql using the following command:

$ npm install mysql

  • Since we can build and handle connections one at a time, we’ll use MySQL connection pooling in this case .createPool(config)
  • Now we can create a pool and use directly:

We need to add a DB_INSTANCE_NAME with the instance name in the Overview tab until we can deploy the API to Google App Engine (GAE).

Related Posts

Latest Posts

  • All Posts
  • AI Powered Knowledge
  • ai/ml
  • CEO India Magazine
  • CMMI level 5 Certification
  • e-learning
  • Fintech
  • gaming
  • Generative AI
  • healthcare
  • manufacturing
  • News
  • OTT
  • Portfolio
  • supply chain
  • travel and hospitality
  • Tudip's AI Hackathon
  • Voxlearn Enterprises
    •   Back
    • Android
    • iOS
    • Java
    • PHP
    • MEAN
    • Ruby
    • DotNet
    • IoT
    • Cloud
    • Testing
    • Roku
    • CMS
    • Python
The Future of Workplace Learning: AI-Powered Knowledge on Demand

The Future of Workplace Learning: AI-Powered Knowledge on Demand

June 12, 2026

A few months ago, I was sitting in a meeting with a team lead who looked genuinely frustrated. Not because…

Read More
We Built VoXlearn Because Enterprise Training Was Broken: Here’s What We Did About It

We Built VoXlearn Because Enterprise Training Was Broken: Here’s What We Did About It

June 12, 2026

If you’ve ever sat through an end-of-quarter training report and thought, “We spent all that time and money, and this…

Read More
We Did It Again: Tudip Successfully Renews Its CMMI Level 5 Certification

We Did It Again: Tudip Successfully Renews Its CMMI Level 5 Certification

June 9, 2026

Nobody around here needed a memo to know something worth celebrating had happened. The message from the CMMI Institute said…

Read More

India

Plot No. 11/2, Phase 3, Hinjewadi Rajiv Gandhi Infotech Park, Pune, India – 411057.
info@tudip.com
+91-96-8990-0537

United States

1999 S. Bascom Ave Suite 700, Campbell CA. 95008, USA.
info@tudip.com
+1-408-216-8162

Canada

64 Caracas Road North York, Toronto Ontario M2K 1B1, Canada.
info@tudip.com

Mexico

Calle Amado Nervo #785 Interior B Colonia Ladron De Guevara 44600 Guadalajara, Jalisco, Mexico.
info@tudip.com

Singapore

77 High Street, #10-12B High Street Plaza, Singapore 179433.
info@tudip.com

Colombia

Cra. 9 # 113-53 Of. 1405 Bogotá D.C., Colombia.
info@tudip.com

UAE

Tudip Information Technologies L.L.C Office No 109, ABU HAIL BUILDING 13, Abu Hail, Dubai, UAE.
info@tudip.com

Nigeria

22 Kumasi Crescent, Wuse 2, Abuja, Nigeria.
info@tudip.com