tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > Google Gemini API > ADK with Cloud Spanner

ADK with Cloud Spanner

Author: Venkata Sudhakar

Cloud Spanner is a globally distributed, strongly consistent relational database. When ADK agents need to read or write transactional business data - orders, inventory, customer records - Cloud Spanner provides ACID guarantees at scale. ShopMax India uses Spanner as the backend for its order management agent tools, ensuring inventory updates and order placements are always consistent across regions.

Spanner is accessed from ADK tools using the google-cloud-spanner client library. Read operations use snapshots for performance; write operations use read-write transactions for consistency. The agent calls these tools like any other function - the Spanner complexity is hidden behind a clean interface.

The below example shows ADK tools that read order data and update inventory using Cloud Spanner.


It gives the following output,

Spanner client connected: shopmax-india/shopmax_orders
Tools registered: get_order, update_order_status

The below example shows the ADK agent using these Spanner-backed tools to handle a customer order status query and escalation.


It gives the following output,

Order ORD-5521 found:
  Customer: CUST-BLR-00421 | City: Bangalore
  Current status: CONFIRMED | Amount: Rs 45,000

Order ORD-5521 has been updated to SHIPPED successfully.
The customer in Bangalore will receive delivery tracking details shortly.

ShopMax India processes 15,000 orders daily through its Spanner-backed agent tools. Spanner multi-region replication ensures that an order placed in Delhi is immediately visible to an agent handling a query from the Hyderabad support team. The ACID transaction guarantees mean inventory is never oversold - a critical requirement for high-demand product launches and flash sales.


 
  


  
bl  br