📖 Scenario: You are setting up a Cloud SQL instance on Google Cloud Platform. Cloud SQL supports three main database engines: MySQL, PostgreSQL, and SQL Server. You want to create a configuration dictionary that lists these supported engines and their default versions.
🎯 Goal: Create a Python dictionary that holds the supported Cloud SQL engines as keys and their default versions as values. Then, add a configuration variable to select the default engine. Next, write code to extract the version of the selected engine. Finally, complete the configuration by adding a key for the region where the Cloud SQL instance will be deployed.
📋 What You'll Learn
Create a dictionary called cloud_sql_engines with keys 'MySQL', 'PostgreSQL', and 'SQL Server' and their default versions as values.
Create a variable called default_engine and set it to 'PostgreSQL'.
Write code to get the version of the default_engine from cloud_sql_engines and store it in selected_version.
Add a key 'region' with value 'us-central1' to the cloud_sql_engines dictionary.
💡 Why This Matters
🌍 Real World
Cloud SQL is a managed database service on Google Cloud Platform that supports popular database engines. Knowing how to configure supported engines and their versions is essential when setting up databases for applications.
💼 Career
Cloud engineers and developers often need to configure and manage Cloud SQL instances. Understanding how to represent and manipulate configuration data programmatically helps automate deployments and maintain infrastructure.
Progress0 / 4 steps
1
Create the Cloud SQL engines dictionary
Create a dictionary called cloud_sql_engines with these exact entries: 'MySQL': '8.0', 'PostgreSQL': '14', and 'SQL Server': '2019'.
GCP
Hint
Use curly braces {} to create a dictionary with the given keys and values.
2
Set the default engine
Create a variable called default_engine and set it to the string 'PostgreSQL'.
GCP
Hint
Assign the string 'PostgreSQL' to the variable default_engine.
3
Get the version of the selected engine
Write code to get the version of the engine stored in default_engine from the cloud_sql_engines dictionary and assign it to a variable called selected_version.
GCP
Hint
Use the default_engine variable as the key to get the version from cloud_sql_engines.
4
Add the region to the configuration
Add a new key 'region' with the value 'us-central1' to the cloud_sql_engines dictionary.
GCP
Hint
Use square brackets to add a new key-value pair to the dictionary.
Practice
(1/5)
1. Which database engines are supported by Google Cloud SQL?
easy
A. SQLite, Cassandra, and MariaDB
B. Oracle, MongoDB, and Redis
C. Firebase, Bigtable, and Spanner
D. MySQL, PostgreSQL, and SQL Server
Solution
Step 1: Recall supported engines in Cloud SQL
Google Cloud SQL supports three main database engines: MySQL, PostgreSQL, and SQL Server.
Step 2: Compare options with supported engines
Only MySQL, PostgreSQL, and SQL Server lists these three engines correctly; others list unsupported or different services.
Final Answer:
MySQL, PostgreSQL, and SQL Server -> Option D
Quick Check:
Cloud SQL engines = MySQL, PostgreSQL, SQL Server [OK]
Hint: Remember Cloud SQL supports only these three engines [OK]
Common Mistakes:
Confusing Cloud SQL with other GCP database services
Including unsupported engines like Oracle or MongoDB
Mixing NoSQL and SQL engines
2. Which of the following is the correct way to specify the database engine when creating a Cloud SQL instance using gcloud CLI?
easy
A. gcloud sql instances create my-instance --database-version=MYSQL_8_0
B. gcloud sql create instance my-instance --engine=PostgreSQL
C. gcloud sql instances new my-instance --db-engine=SQLSERVER_2019
D. gcloud sql instance create my-instance --version=MySQL8
Solution
Step 1: Identify correct gcloud command syntax
The correct command uses 'gcloud sql instances create' and the flag '--database-version' with uppercase engine and version format.
Step 2: Match options with correct syntax
gcloud sql instances create my-instance --database-version=MYSQL_8_0 matches the correct syntax: 'gcloud sql instances create my-instance --database-version=MYSQL_8_0'. Others use incorrect flags or commands.
Final Answer:
gcloud sql instances create my-instance --database-version=MYSQL_8_0 -> Option A
Step 1: Check required flags for Cloud SQL instance creation
The --region flag (and --tier) is required; both are missing here.
Step 2: Validate other aspects
SQL Server 2017 is supported via SQLSERVER_2017, command syntax is correct, CLI tool is correct.
Final Answer:
Missing required region flag -> Option A
Quick Check:
Missing --region causes failure [OK]
Hint: Always include --region (and --tier) when creating Cloud SQL instances [OK]
Common Mistakes:
Assuming SQL Server 2017 is unsupported
Thinking region flag is optional
Believing a different CLI tool is needed
5. You need a Cloud SQL instance for an app that requires strong Windows authentication support and integration with Microsoft tools. Which engine should you choose and why?
hard
A. MySQL, because it is the most popular and easy to use
B. SQL Server, because it supports Windows authentication and Microsoft integration
C. Any engine, because Cloud SQL handles authentication uniformly
D. PostgreSQL, because it supports advanced JSON features
Solution
Step 1: Identify app requirements
The app needs strong Windows authentication and Microsoft tool integration.
Step 2: Match engine capabilities
SQL Server supports Windows authentication and integrates well with Microsoft tools, unlike MySQL or PostgreSQL.
Step 3: Confirm Cloud SQL engine choice
Choosing SQL Server engine meets the app's specific needs best.
Final Answer:
SQL Server, because it supports Windows authentication and Microsoft integration -> Option B
Quick Check:
Windows auth needs SQL Server engine [OK]
Hint: Choose SQL Server for Windows authentication needs [OK]
Common Mistakes:
Picking MySQL or PostgreSQL ignoring Windows auth needs
Assuming Cloud SQL abstracts all authentication differences
Not considering app-specific integration requirements
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.