Dataflow 讀取 API

使用 Dataflow 連接器,指定資料表名稱和資料欄清單,即可在不使用查詢的情況下讀取資料庫。

深入探索

如需包含這個程式碼範例的詳細說明文件,請參閱下列文章:

程式碼範例

Java

如要瞭解如何安裝及使用 Spanner 的用戶端程式庫,請參閱「Spanner 用戶端程式庫」。

如要向 Spanner 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

// Query for all the columns and rows in the specified Spanner table
PCollection<Struct> records = pipeline.apply(
    SpannerIO.read()
        .withInstanceId(instanceId)
        .withDatabaseId(databaseId)
        .withTable("Singers")
        .withColumns("singerId", "firstName", "lastName"));

後續步驟

如要搜尋及篩選其他 Google Cloud 產品的程式碼範例,請參閱Google Cloud 瀏覽器範例