Instrukcje i wymagania dotyczące konfiguracji modułu
Chroń swoje konto i postępy. Zawsze używaj okna przeglądania prywatnego i danych logowania do modułu, kiedy go uruchamiasz.

Running Queries and Transactions

Laboratorium 1 godz. universal_currency_alt 1 punkt show_chart Wprowadzające
info Ten moduł może zawierać narzędzia AI, które ułatwią Ci naukę.
Te treści nie są jeszcze zoptymalizowane pod kątem urządzeń mobilnych.
Dla maksymalnej wygody odwiedź nas na komputerze, korzystając z linku przesłanego e-mailem.

SCBL006

Overview

In this lab, you learn how to run parameterized queries, create and use indexes, and execute transactions against a Spanner database.

Objectives

In this lab, you learn how to:

  • Run prarameterized queries using indexes against a Spanner database using the Python Client library.
  • Execute transactions against a Spanner database.

Setup and Requirements

Before you click the Start Lab button

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:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab. Remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

Open the lab notebook in Vertex AI Workbench

Open Vertex AI Workbench from the console, and access the pre-created instance from the workbench.

STEPS:

  1. In the Google Cloud console, enter Vertex AI in the top search bar.
  2. Under Categories > Choose Artificial Intellgence , Select Vertex AI, or else you can go to Vertex AI Dashboard
  3. If the Vertex AI APIs are not enabled, click Enable All Recommended APIs.
  4. In the left panel, click the Workbench section and open the INSTANCES tab.
  5. Select the Create New button. Name the Notebook my-notebook, choose the region. You may choose any zone for this region.
  6. Click Machine type from the list on the left, select E2 standard and e2-standard-2 from Advanced options for the Machine type.
  7. When the instance is ready, click the Open JupyterLab link.

Task 1. Programming queries and transactions with Python

  1. Open a new Terminal window from the Launcher or from File>New>Terminal, and run

    git clone https://github.com/GoogleCloudPlatform/training-data-analyst
  2. In the file explorer on the left, navigate to the home directory and open training-data-analyst/courses/understanding-spanner/colab-notebooks/Spanner_Queries_Transactions.ipynb

  3. Run the first cell to install the Python Spanner client library.

  4. 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
  1. Now run the second cell. In this cell, some variables are created and the Spanner API is enabled.

  2. Read the text prior to each code cell and run each one. Take the time to understand what the code is doing.

Conclusion:

Congratulations! You have learned how to run parameterized queries and execute transactions against a Spanner database.

End your lab

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:

  • 1 star = Very dissatisfied
  • 2 stars = Dissatisfied
  • 3 stars = Neutral
  • 4 stars = Satisfied
  • 5 stars = Very satisfied

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.

Zanim zaczniesz

  1. Moduły tworzą projekt Google Cloud i zasoby na określony czas.
  2. Moduły mają ograniczenie czasowe i nie mają funkcji wstrzymywania. Jeśli zakończysz moduł, musisz go zacząć od początku.
  3. Aby rozpocząć, w lewym górnym rogu ekranu kliknij Rozpocznij moduł.

Użyj przeglądania prywatnego

  1. Skopiuj podaną nazwę użytkownika i hasło do modułu.
  2. Kliknij Otwórz konsolę w trybie prywatnym.

Zaloguj się w konsoli

  1. Zaloguj się z użyciem danych logowania do modułu. Użycie innych danych logowania może spowodować błędy lub naliczanie opłat.
  2. Zaakceptuj warunki i pomiń stronę zasobów przywracania.
  3. Nie klikaj Zakończ moduł, chyba że właśnie został przez Ciebie zakończony lub chcesz go uruchomić ponownie, ponieważ spowoduje to usunięcie wyników i projektu.

Ta treść jest obecnie niedostępna

Kiedy dostępność się zmieni, wyślemy Ci e-maila z powiadomieniem

Świetnie

Kiedy dostępność się zmieni, skontaktujemy się z Tobą e-mailem

Jeden moduł, a potem drugi

Potwierdź, aby zakończyć wszystkie istniejące moduły i rozpocząć ten

Aby uruchomić moduł, użyj przeglądania prywatnego

Najlepszym sposobem na uruchomienie tego laboratorium jest użycie okna incognito lub przeglądania prywatnego. Dzięki temu unikniesz konfliktu między swoim kontem osobistym a kontem do nauki, co mogłoby spowodować naliczanie dodatkowych opłat na koncie osobistym.