
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
In this lab, you run the Python code to create Spanner instances and databases. You also see how to create, retrieve, and delete records from databases using both the Google Standard SQL and PostgreSQL dialects.
In this lab, you learn how to:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.
This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. The output contains a line that declares the PROJECT_ID for this session:
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Click Authorize.
Your output should now look like this:
Output:
Output:
Example output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Tip: You can also search for Dataflow Workbench
using the Search box in the Console toolbar.
If the Enable Notebooks API link appears, click the link to activate the API.
From the Workbench page, click the Create New button.
Click Machine type from the list on the left, select E2 standard and e2-standard-2 for the Machine type.
Leave the remaining fields at their default and click Create.
When the instance is ready, click the Open Jupyter link. This opens Jupyter in another browser tab.
In the file explorer on the left, navigate to training-data-analyst/courses/understanding-spanner/colab-notebooks/Spanner_Samples_Python.ipynb and open that file.
Run the first cell to install the Python Spanner client library.
In the second cell, update the following variables as listed:
Variable | New Value (In the notebook, please leave the outside single quotes) |
---|---|
project_id | |
region_id |
Now run the second cell. In this cell, some variables are created and the Spanner API is enabled.
Read the text prior to each code cell and run each one. Take the time to understand what the code is doing.
Open the file: training-data-analyst/courses/understanding-spanner/colab-notebooks/Spanner_PostgeSQL.ipynb.
Run the first cell to confirm the Python Spanner client library is active.
In the second cell, update the following variables as listed:
Variable | New Value (In the notebook, please leave the outside single quotes) |
---|---|
project_id | |
region_id |
Now run the second cell. In this cell, some variables are created and the Spanner API is enabled.
Examine and run each of the steps in the notebook.
When you have completed your lab, click End Lab. Your account and the resources you've used are removed from the lab platform.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2023 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one