Connector for Cloud Spanner

Workflows connector that defines the built-in function used to access Cloud Spanner within a workflow.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

YAML

# This workflow demonstrates how to use the Cloud Spanner connector to write
# some entries to an existing database.
# Expected successful output: "SUCCESS"
- create_table_entry:
    assign:
      - entry: ["123"]
- create_txn:
    assign:
      - req:
          mutations:
            - insert:
                columns:
                  - ID
                table: Contacts
                values:
                  - ${entry}
          singleUseTransaction:
            readWrite: {}
- create_spanner_session:
  call: googleapis.spanner.v1.projects.instances.databases.sessions.create
  args:
    database: projects/placeholder/instances/placeholder-instance-name/databases/placeholder-database-name
  result: session
- write_entry:
  call: googleapis.spanner.v1.projects.instances.databases.sessions.commit
  args:
    session: ${session.name}
    body: ${req}
- delete_spanner_session:
  call: googleapis.spanner.v1.projects.instances.databases.sessions.delete
  args:
    name: ${session.name}
- the_end:
    return: SUCCESS

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.