blog image
Blog Articles

Crafting a Database on Google Cloud Platform: Guide

In today’s digital age, businesses and organizations are continually striving to scale, innovate, and streamline their operations. Google Cloud Platform (GCP), a dominant force in cloud computing, offers a comprehensive suite of services tailored to meet the diverse requirements of modern enterprises. In this blog post, we’ll delve into what GCP is, its key features, and how it can benefit your business, whether you’re involved in custom financial software development, software development for financial services, custom enterprise software development, or seeking an iOS mobile app development company.

What is Google Cloud Platform (GCP)?

Google Cloud Platform, often referred to as GCP, is a suite of cloud computing services that provide a scalable and flexible infrastructure for software application development. It’s one of the major players in the cloud industry, competing with other giants like Amazon Web Services (AWS) and Microsoft Azure. GCP offers a wide range of services, including computing, storage, databases, machine learning, and analytics, all hosted on Google’s highly reliable and secure global network.

Key Features of GCP:

Global Network: Google Cloud Platform leverages Google’s extensive global network infrastructure, ensuring high availability and low-latency access to services across the globe.

Compute Services: Google Cloud Platform provides a variety of virtual machine options, including Google Compute Engine, which allows you to run workloads at scale.

Storage Services: With Google Cloud Storage and Cloud SQL, GCP offers secure, durable, and highly available storage solutions for your data.

Big Data and Analytics: Google’s BigQuery and Dataflow services enable you to process and analyze large datasets with ease.

Machine Learning: GCP’s AI and machine learning services, like AI Platform and AutoML, empower you to build and deploy ML models without specialized expertise.

Security and Compliance: Google Cloud Platform prioritizes security, with features like Identity and Access Management (IAM) and encryption to protect your data.

Serverless Computing: GCP’s serverless offerings, such as Cloud Functions and App Engine, simplify application deployment and management.

Benefits of Using GCP:

Scalability: GCP allows you to scale your resources up or down as needed, so you pay only for what you use, making it cost-effective for businesses of all sizes.

Reliability: Google’s infrastructure is known for its high uptime, ensuring that your applications and data are available when you need them.

Innovation: GCP provides access to cutting-edge technologies, such as AI and machine learning, enabling you to stay ahead of the competition.

Global Reach: With data centers in multiple regions, GCP offers global coverage, allowing you to reach your customers wherever they are.

Ease of Use: GCP’s user-friendly interface and extensive documentation make it accessible to both seasoned developers and newcomers to cloud computing.In this vast ocean of services, we are going to create a Cloud SQL Database and connect to it. We are going to see the connection with the created DB, both by the package provided by GCP and also simply by Prisma. Whether you choose to work with dedicated offshore developers or an in-house team, understanding the process of setting up and connecting to a Cloud SQL Database is essential for successful application development.

To create Cloud SQL DB follow this step by step guide.

1. Log in to Google Cloud Console:

Sign in with your Google account credentials.
If you don’t have a Google account, you’ll need to create one.

2. Select or Create a Project:

If you’re working on an existing project, select it from the dropdown in the top navigation bar.

If you need to create a new project, click on the project name and then click “New Project.”

A.



B.


C.
Enter the details and create project

3. Enable Billing:

Before you can create Cloud SQL instances, you need to enable billing for your project. If you haven’t already done this, you’ll see a notification prompting you to enable billing.

4. Open the Cloud SQL Page:

In the Cloud Console, click on the navigation menu (the three horizontal lines) and go to “SQL” under the “Databases” section.

5. Click “Create Instance”:

On the Cloud SQL page, click the “Create instance” button.

Now choose the instance you want to create for –



6. Configure Instance Details:

In the “Instance ID” field, enter a unique name for your Cloud SQL instance.

Choose the database engine you want to use (e.g., MySQL, PostgreSQL, SQL Server).

Select your preferred location (region) for the instance.

Choose the database version.

Set the machine type and storage capacity.

Configure your database instance with a password for the master user.

Optionally, enable automatic backups and maintenance.
The below is a screenshot for Configuration page –

Click “Create” to create the instance.


7. Wait for Instance Creation:

Google Cloud will take a few moments to create your Cloud SQL instance. You can monitor the progress on the “SQL instances” page. It can take upto few minutes.

8. Configure Access Control:

Once the instance is created, you’ll want to configure access control. You can set up authorized networks, create users, and manage access to your database from the “Users” and “Authorized networks” tabs under your instance’s details.
To create Authorized networks :
Go to connection, and In the authorized networks add the IP address of your device. If you want to allow all traffic just enter “0.0.0.0/0”. Give the IP address a name and click DONE.

If You want to create user –


Go to Users, then click on Add User Account –


Now set up the authorization setting, and click ADD


9. Connect to Your Cloud SQL Database:
You can connect to your Cloud SQL database using various methods, including using the Google Cloud SDK, Cloud Shell, or third-party database tools like pgAdmin or prisma and many more.
We will discuss two ways for how to connect to this instance and fire queries.
By Using “sql-connector” package by GCP –
GCP provides a “sql-connector” package which can we leveraged for establishing connection and firing SQL query. In this example we are using the “node-sql-connector” package.
More information regarding this package will be available at – LINK.
Firstly compose your GCP creds in a JSON file and store it in your project.
In ‘.env’ file give the path of that JSON file with key as “GOOGLE_APPLICATION_CREDENTIALS”.

Below is a sample code to form the connection “pool” using which we can fire sql query.

SAMPLE OUTPUT –


As you can see we can fire a query and the expected response is fetched.

Now that your Cloud SQL instance is up and running, you can create databases, tables, and manage your data using SQL commands or database management tools.

Sign Up Now
Get a Fast Estimate on Your Software Development Project

We are committed to delivering high-quality IT solutions tailored to meet the unique needs of our clients. As part of our commitment to transparency and excellence, we provide detailed project estimations to help our clients understand the scope, timeline, and budget associated with their IT initiatives.

Related Blog Posts

Statically Typed vs Dynamically Typed Languages: A Deep Dive

One of the most important aspects of any programming language is how it treats types and what types it can, or cannot, handle. This is known as its “typing discipline,”…

View Article
Spring JPA: Key Components for Custom Software Development

One of such pivotal issues here is a scalable data access options—sustainable and scalable—that we can see growing in importance with every new custom software development project. It could be…

View Article
The Power of Rich Text Editing with jodit-react

Introduction Rich text editors have become an inseparable part of the web development services world now and every platform has to ensure that software development companies and users have an…

View Article
Ace Editor Mastery: Enhancing Your Code Editing Skills with React

Among website development and mobile application development, A code editor can increase the code editing efficiency and the working conduct, finally leading to program structure perfection, workflow optimization and development…

View Article
Zustand: A Lightweight State Management Library for React

One of the most essential things when it comes to creating modern web applications, particularly projects in React, is state management. Whilst the built-in state management hooks of React such…

View Article
Smartlook Integration in Ionic App

Introduction When it comes to mobile apps, a smooth and intuitive user experience is absolutely necessary in the current competitive mobile app market. App developers should not forget about user…

View Article