This directory contains an idiomatic C++ client library for interacting with Google Cloud Spanner, which is a fully managed, scalable, relational database service for regional and global application data.
While this library is GA, please note that the Google Cloud C++ client libraries do not follow Semantic Versioning.
The quickstart/ directory contains a minimal environment to get started using this client library in a larger project. The following "Hello World" program is used in this quickstart, and should give you a taste of this library.
#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;
}
- Packaging maintainers or developers who prefer to install the library in a
fixed directory (such as
/usr/local
or/opt
) should consult the packaging guide. - Developers who prefer using a package manager such as vcpkg, or Conda, should follow the instructions for their package manager.
- Developers wanting to use the libraries as part of a larger CMake or Bazel project should consult the quickstart guides for the library or libraries they want to use.
- Developers wanting to compile the library just to run some examples or tests should read the project's top-level README.
- Contributors and developers to
google-cloud-cpp
should consult the guide to set up a development workstation.
- Official documentation about the Cloud Spanner service
- Reference doxygen documentation for each release of this client library
- Detailed header comments in our public
.h
files