image
Initializing a Data System with Products
Start course
Difficulty
Beginner
Duration
55m
Students
1933
Ratings
4.4/5
Description

*** NOTICE: This course contains outdated information and has been deprecated ***

This course has been designed to teach you how to deploy and implement Google Cloud Platform solutions. The content in this course will help prepare you for the Associate Cloud Engineer exam.

Learning Objectives

  • To learn how to deploy Kubernetes Engine resources on Google Cloud Platform
  • To learn how to deploy and implement App Engine and Cloud Functions resources
  • To learn how to use Cloud Launcher and Deployment Manager

Intended Audience

  • Those who are preparing for the Associate Cloud Engineer exam
  • Those looking to learn more about GCP networking and compute features

Prerequisites

To get the most from this course then you should have some exposure to GCP resources, such as Kubernetes Engine, App Engine, Cloud Functions, Cloud Launcher, and Deployment Manager. However, this is not essential.

Transcript

There may be times when you need to upload data to other services, such as Cloud SQL. For example, you may want to initialize your data system with an inventory of products. In this demonstration, I'm going to show you how to connect to a Cloud SQL instance, how to create a database, and then how to upload data to that database. 

We'll do this via Cloud Shell. 

Now to prepare for this exercise, I've already provisioned a MySQL instance, called myinstance. 

To connect to myinstance and upload my data or initialize that seed data, I'm going to launch my Cloud Shell. Let's go ahead and do that here. Let's drag this up here. 

Now, from the Cloud Shell prompt, I'm going to run a gcloud SQL connect command here. So let's type it in here. Now what this is going to do is white-list my IP address so I can connect to SQL. 

As you can see here, I am prompted for the root password that I created when I created the instance. So I'll go ahead and enter it here. 

Now once I've done that, I'm presented with the MySQL prompt. Now to create my SQL database, I need to run a create command. So let's go ahead and do that now. We'll type in create and then database and we'll call it mydatabase. We can see by the query OK that my database creation was successful. 

Now that my database is created, I can begin uploading data, but before I do that, I need to create a table and to do that, I need to use the create table command. Now before running the create table command, I'm going to run a use command to make sure I'm using my database. So now we're connected to my database. What this use command does is essentially specify the database that I want to work with. 

Now with my database selected, I need to create my table. Now what I'm going to do here is I'm going to copy the create table command over because it's rather lengthy. This create table command creates a table within my database and creates three columns within that table. It creates a product name column, a content column, and an entry ID column. It also sets the entry ID column as the primary key for the table. 

Let's go ahead and hit Enter here to create our table. And we can see that the query is OK so we're good. So with my table created, I'm going to run an insert command to add an apple as a product and red delicious as the content for that apple. And what I'll do here is I'll copy it over. So you can see what we're going to do is run an INSERT INTO command to insert data into our entries table. Now the entries table is the table that we created up here. 

What we're going to do is insert apple as our product name and red delicious, which is a type of apple, as the content. So essentially what we're going to do is build an inventory or initialize an inventory of products. So we'll go ahead and hit Enter here. And we can see our query was OK with one row affected. Now I'll run the same command again to add another type of apple into my inventory. This time we'll do a Cortland apple. So as you can see here, this is how I can initialize something like an inventory system with product using basic insert commands. 

Now to retrieve the data that I entered, I simply run a select command. So what we'll do is we'll run select and then we'll specify star, which means return everything, and we'll select from our entries table. I forgot my semicolon. And there we go. And just to show you what happened here, when I ran the select command, I forgot the trailing semicolon here to denote the end of the command, so it was looking for more info. And that's what it's telling me here. We had an error in our SQL syntax but once I ran the command correctly, select star from entries semicolon, it returns all of the entries from our entries table. 

And we can see here apple as our product name, red delicious. Apple as another productive name and Cortland. Now of course this is a simple demonstration, but it does give you an idea of what's involved in creating databases and initializing them with product data.

About the Author
Students
90559
Courses
89
Learning Paths
56

Tom is a 25+ year veteran of the IT industry, having worked in environments as large as 40k seats and as small as 50 seats. Throughout the course of a long an interesting career, he has built an in-depth skillset that spans numerous IT disciplines. Tom has designed and architected small, large, and global IT solutions.

In addition to the Cloud Platform and Infrastructure MCSE certification, Tom also carries several other Microsoft certifications. His ability to see things from a strategic perspective allows Tom to architect solutions that closely align with business needs.

In his spare time, Tom enjoys camping, fishing, and playing poker.

Covered Topics