All skills
google avatar

/spanner-basics

@becc4b8
by googlegoogle/skills21k stars
1,698

Assists in provisioning instances and databases, designing performant schemas, and querying data in Spanner. Use when designing primary keys, writing SQL queries or client library code, or diagnosing performance issues.

Use this Skill: https://skilld.dev/gh/google/skills/spanner-basics

This session only. Nothing lands on disk.

referencesclient-library-usage.md

≈898 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Client Library Usage

Instructions on how to install the Google Cloud SDK can be found at Install the Google Cloud SDK.

Client Libraries

Google Cloud client libraries provide an idiomatic way to interact with Spanner from your preferred programming language.

Python

  • Installation:

    pip install google-cloud-spanner
  • Usage Example:

    from google.cloud import spanner
    
    spanner_client = spanner.Client()
    instance = spanner_client.instance("my-instance-id")
    database = instance.database("my-database-id")
    with database.snapshot() as snapshot:
        results = snapshot.execute_sql("SELECT 1")
        for row in results:
            print(row)
  • Python Reference

Java

  • Maven Dependency:

    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-spanner</artifactId>
    </dependency>
  • Usage Example:

    SpannerOptions options = SpannerOptions.newBuilder().build();
    Spanner spanner = options.getService();
    DatabaseClient dbClient = spanner.getDatabaseClient(DatabaseId.of(options.getProjectId(), "my-instance-id", "my-database-id"));
    ResultSet resultSet = dbClient.singleUse().executeQuery(Statement.of("SELECT 1"));
    while (resultSet.next()) {
        System.out.println(resultSet.getLong(0));
    }
  • Java Reference

Node.js

  • Installation:

    npm install @google-cloud/spanner
  • Usage Example:

    const {Spanner} = require("@google-cloud/spanner");
    
    const spanner = new Spanner({projectId: "my-project-id"});
    const instance = spanner.instance("my-instance-id");
    const database = instance.database("my-database-id");
    const [rows] = await database.run({sql: "SELECT 1"});
  • Node.js Reference

Go

  • Installation:

    go get cloud.google.com/go/spanner
  • Usage Example:

    ctx := context.Background()
    client, err := spanner.NewClient(ctx, "projects/my-project-id/instances/my-instance-id/databases/my-database-id")
    if err != nil {
        log.Fatalf("Failed to create client: %v", err)
    }
    defer client.Close()
    iter := client.Single().Query(ctx, spanner.Statement{SQL: "SELECT 1"})
    defer iter.Stop()
  • Go Reference

Additional Libraries

LangChain Integration

Spanner integrates with LangChain to help you build LLM-powered applications.

  • Vector Store: Use SpannerVectorStore to store and search vector embeddings.
  • Document Loader: Use SpannerLoader to load data from Spanner.
  • Chat Message History: Use SpannerChatMessageHistory to store conversation history.

For more information, see the Spanner guide for LangChain.

Spring Data Spanner

For Java applications using the Spring Framework, the Spring Data Spanner module provides a familiar Spring Data interface.

For more information, see Add Spring Data Spanner to your application.

Source: SKILL.md on GitHub

No alerts10d3 checks · Risk SAFE
  • Gen Agent Trust Hub10d

    This skill is designed to assist with Google Cloud Spanner administration and development. It provides standard workflows for schema design, SQL querying, and resource management using official Google tools and libraries. It includes appropriate safety guardrails requiring user confirmation for destructive database operations.

  • Socket10d

    No alerts

  • Snyk10d

    Risk: LOW · No issues

Signed by skilld at becc4b8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 weeks ago
metadata
{
  "version": "1.0.0",
  "category": "Databases"
}

README badge

README badge for google/skills/spanner-basics