Library reference docs
Namespaces
google::cloud::spanner
Classes
Client
Functions
DatabaseAdminClient
Functions
LimitedErrorCountTransactionRerunPolicy
LimitedTimeTransactionRerunPolicy
Structs
Functions
Operators
google::cloud::spanner_admin
Classes
DatabaseAdminClient
Functions
DatabaseAdminConnectionIdempotencyPolicy
DatabaseAdminLimitedErrorCountRetryPolicy
DatabaseAdminLimitedTimeRetryPolicy
InstanceAdminClient
Functions
InstanceAdminConnectionIdempotencyPolicy
InstanceAdminLimitedErrorCountRetryPolicy
InstanceAdminLimitedTimeRetryPolicy
Structs
google::cloud::spanner_admin_mocks
Stay organized with collections Save and categorize content based on your preferences.
The Cloud Spanner C++ Client library offers types and functions to use Cloud Spanner from C++ applications.
QuickstartThe following "Hello World" program should give you a sense of how to use this library. This program is also used to illustrate how to incorporate the library into your project.
#include "google/cloud/spanner/client.h"
#include <iostream>
int main(int argc, char* argv[]) {
if (argc != 4) {
std::cerr << "Usage: " << argv[0]
<< " project-id instance-id database-id\n";
return 1;
}
namespace spanner = ::google::cloud::spanner;
spanner::Client client(
spanner::MakeConnection(spanner::Database(argv[1], argv[2], argv[3])));
auto rows =
client.ExecuteQuery(spanner::SqlStatement("SELECT 'Hello World'"));
for (auto const& row : spanner::StreamOf<std::tuple<std::string>>(rows)) {
if (!row) {
std::cerr << row.status() << "\n";
return 1;
}
std::cout << std::get<0>(*row) << "\n";
}
return 0;
}
More Information
Client::ExecuteQuery()
to execute SQL queries in Cloud Spanner.Client::Commit()
to execute read-write transactions in Cloud Spanner.Client::Read()
to read the rows in a table.Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["This webpage provides documentation for the Cloud Spanner C++ Client library, which enables C++ applications to interact with Cloud Spanner."],["The latest version of the client library is 2.37.0-rc, and there are many previous versions available listed such as 2.36.0, 2.23.0, and 2.11.0."],["The library supports executing SQL queries, committing read-write transactions, and reading table rows in Cloud Spanner through functions like `Client::ExecuteQuery()`, `Client::Commit()`, and `Client::Read()`."],["The documentation includes information on error handling, environment variables, retry policies, custom endpoint configuration, custom authentication configuration, and mocking the client with Google Mock."],["A quickstart \"Hello World\" example is provided to illustrate how to use the library and integrate it into a project, and a guide to setting up a C++ development environment is linked."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4