12 stable releases

1.8.1 Jun 2, 2026
1.8.0 Mar 19, 2026
1.7.0 Jan 25, 2026
1.6.0 Dec 22, 2025
1.0.0 Feb 7, 2025

#311 in Database interfaces

Download history 7774/week @ 2026-02-23 9313/week @ 2026-03-02 11188/week @ 2026-03-09 5566/week @ 2026-03-16 7722/week @ 2026-03-23 7203/week @ 2026-03-30 11179/week @ 2026-04-06 12391/week @ 2026-04-13 13565/week @ 2026-04-20 10637/week @ 2026-04-27 10130/week @ 2026-05-04 9784/week @ 2026-05-11 18414/week @ 2026-05-18 22688/week @ 2026-05-25 31621/week @ 2026-06-01 56647/week @ 2026-06-08

130,689 downloads per month
Used in 4 crates (3 directly)

MIT license

3.5MB
39K SLoC

google-cloud-spanner

Google Cloud Platform spanner library.

crates.io

Installation

[dependencies]
google-cloud-spanner = { package="gcloud-spanner", version="1.0.0" }

Quickstart

Create Client and call transaction API same as Google Cloud Go.

 use google_cloud_spanner::client::Client;
 use google_cloud_spanner::mutation::insert;
 use google_cloud_spanner::statement::Statement;
 use google_cloud_spanner::value::CommitTimestamp;
 use google_cloud_spanner::client::Error;

 #[tokio::main]
 async fn main() -> Result<(), Error> {

     const DATABASE: &str = "projects/local-project/instances/test-instance/databases/local-database";

     // Create spanner client
     let config = ClientConfig::default().with_auth().await.unwrap();
     let mut client = Client::new(DATABASE, config).await.unwrap();

     // Insert
     let mutation = insert("Guild", &["GuildId", "OwnerUserID", "UpdatedAt"], &[&"guildId", &"ownerId", &CommitTimestamp::new()]);
     let commit_timestamp = client.apply(vec![mutation]).await?;

     // Read with query
     let mut stmt = Statement::new("SELECT GuildId FROM Guild WHERE OwnerUserID = @OwnerUserID");
     stmt.add_param("OwnerUserID",&"ownerId");
     let mut tx = client.single().await?;
     let mut iter = tx.query(stmt).await?;
     while let Some(row) = iter.next().await? {
         let guild_id = row.column_by_name::<String>("GuildId");
     }

     // Remove all the sessions.
     client.close().await;
     Ok(())
 }

Performance

Result of the 24 hours Load Test.

Metrics This library Google Cloud Go
RPS 438.4 443.4
Used vCPU 0.37 ~ 0.42 0.65 ~ 0.70

Test condition

  • 2.0 vCPU GKE Autopilot Pod
  • 1 Node spanner database server
  • 100 Users
  • Here is the application for Load Test.

Dependencies

~16–44MB
~720K SLoC