project_id(String) — Project identifier for the Spanner service you
are connecting to. If not present, the default project for the
credentials is used.
credentials(String, Hash, Google::Auth::Credentials) — The path to
the keyfile as a String, the contents of the keyfile as a Hash, or a
Google::Auth::Credentials object. (SeeSpanner::Credentials)
timeout(Integer)(defaults to: nil)— Default timeout to use in requests. Optional.
lib_name(String)(defaults to: nil)— Library name. This will be added as a prefix
to the API call tracking headerx-goog-api-clientwith provided
lib version for telemetry. Optional. For example prefix looks likespanner-activerecord/0.0.1 gccl/1.13.1. Here,spanner-activerecord/0.0.1is provided custom library name and
version andgccl/1.13.1represents the Cloud Spanner Ruby library
with version.
lib_version(String)(defaults to: nil)— Library version. This will be added as a
prefix to the API call tracking headerx-goog-api-clientwith
provided lib name for telemetry. Optional. For example prefix look likespanner-activerecord/0.0.1 gccl/1.13.1. Here,spanner-activerecord/0.0.1is provided custom library name and
version andgccl/1.13.1represents the Cloud Spanner Ruby library
with version.
timeout(Integer)(defaults to: nil)— Default timeout to use in requests. Optional.
lib_name(String)(defaults to: nil)— Library name. This will be added as a prefix
to the API call tracking headerx-goog-api-clientwith provided
lib version for telemetry. Optional. For example prefix looks likespanner-activerecord/0.0.1 gccl/1.13.1. Here,spanner-activerecord/0.0.1is provided custom library name and
version andgccl/1.13.1represents the Cloud Spanner Ruby library
with version.
lib_version(String)(defaults to: nil)— Library version. This will be added as a
prefix to the API call tracking headerx-goog-api-clientwith
provided lib name for telemetry. Optional. For example prefix look likespanner-activerecord/0.0.1 gccl/1.13.1. Here,spanner-activerecord/0.0.1is provided custom library name and
version andgccl/1.13.1represents the Cloud Spanner Ruby library
with version.
[[["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-09-04 UTC."],[],[],null,["# Cloud Spanner API - Module Google::Cloud (v2.27.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.27.0 (latest)](/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud)\n- [2.26.0](/ruby/docs/reference/google-cloud-spanner/2.26.0/Google-Cloud)\n- [2.25.0](/ruby/docs/reference/google-cloud-spanner/2.25.0/Google-Cloud)\n- [2.24.0](/ruby/docs/reference/google-cloud-spanner/2.24.0/Google-Cloud)\n- [2.23.0](/ruby/docs/reference/google-cloud-spanner/2.23.0/Google-Cloud)\n- [2.22.0](/ruby/docs/reference/google-cloud-spanner/2.22.0/Google-Cloud)\n- [2.21.0](/ruby/docs/reference/google-cloud-spanner/2.21.0/Google-Cloud)\n- [2.20.0](/ruby/docs/reference/google-cloud-spanner/2.20.0/Google-Cloud)\n- [2.19.1](/ruby/docs/reference/google-cloud-spanner/2.19.1/Google-Cloud)\n- [2.18.1](/ruby/docs/reference/google-cloud-spanner/2.18.1/Google-Cloud)\n- [2.17.0](/ruby/docs/reference/google-cloud-spanner/2.17.0/Google-Cloud)\n- [2.16.1](/ruby/docs/reference/google-cloud-spanner/2.16.1/Google-Cloud)\n- [2.15.0](/ruby/docs/reference/google-cloud-spanner/2.15.0/Google-Cloud)\n- [2.14.0](/ruby/docs/reference/google-cloud-spanner/2.14.0/Google-Cloud)\n- [2.13.0](/ruby/docs/reference/google-cloud-spanner/2.13.0/Google-Cloud)\n- [2.12.1](/ruby/docs/reference/google-cloud-spanner/2.12.1/Google-Cloud)\n- [2.11.0](/ruby/docs/reference/google-cloud-spanner/2.11.0/Google-Cloud) \nReference documentation and code samples for the Cloud Spanner API module Google::Cloud.\n\nMethods\n-------\n\n### .spanner\n\n def self.spanner(project_id = nil, credentials = nil, scope: nil, timeout: nil, lib_name: nil, lib_version: nil) -\u003e Google::Cloud::Spanner::Project\n\nCreates a new object for connecting to the Spanner service.\nEach call creates a new connection.\n\n\n\u003cbr /\u003e\n\nFor more information on connecting to Google Cloud see the\n[Authentication Guide](./AUTHENTICATION \"Authentication Guide\"). \n**Parameters**\n\n- **project_id** (String) --- Project identifier for the Spanner service you are connecting to. If not present, the default project for the credentials is used.\n- **credentials** (String, Hash, Google::Auth::Credentials) --- The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See [Spanner::Credentials](/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Credentials \"Google::Cloud::Spanner::Credentials (class)\"))\n- **scope** (String, Array\\\u003cString\\\u003e) *(defaults to: nil)* ---\n\n The OAuth 2.0 scopes controlling the\n set of resources and operations that the connection can access. See\n [Using OAuth 2.0 to Access Google\n APIs](https://developers.google.com/identity/protocols/OAuth2).\n\n The default scopes are:\n - `https://www.googleapis.com/auth/spanner`\n - `https://www.googleapis.com/auth/spanner.data`\n- **timeout** (Integer) *(defaults to: nil)* --- Default timeout to use in requests. Optional.\n- **lib_name** (String) *(defaults to: nil)* --- Library name. This will be added as a prefix to the API call tracking header `x-goog-api-client` with provided lib version for telemetry. Optional. For example prefix looks like `spanner-activerecord/0.0.1 gccl/1.13.1`. Here, `spanner-activerecord/0.0.1` is provided custom library name and version and `gccl/1.13.1` represents the Cloud Spanner Ruby library with version.\n- **lib_version** (String) *(defaults to: nil)* --- Library version. This will be added as a prefix to the API call tracking header `x-goog-api-client` with provided lib name for telemetry. Optional. For example prefix look like `spanner-activerecord/0.0.1 gccl/1.13.1`. Here, `spanner-activerecord/0.0.1` is provided custom library name and version and `gccl/1.13.1` represents the Cloud Spanner Ruby library with version. \n**Returns**\n\n- ([Google::Cloud::Spanner::Project](./Google-Cloud-Spanner-Project))\n**Example** \n\n```ruby\nrequire \"google/cloud\"\n\nspanner = Google::Cloud.spanner\n```\n\n### #spanner\n\n def spanner(scope: nil, timeout: nil, lib_name: nil, lib_version: nil) -\u003e Google::Cloud::Spanner::Project\n\nCreates a new object for connecting to the Spanner service.\nEach call creates a new connection.\n\n\n\u003cbr /\u003e\n\nFor more information on connecting to Google Cloud see the\n[Authentication Guide](./AUTHENTICATION \"Authentication Guide\"). \n**Parameters**\n\n- **scope** (String, Array\\\u003cString\\\u003e) *(defaults to: nil)* ---\n\n The OAuth 2.0 scopes controlling the\n set of resources and operations that the connection can access. See\n [Using OAuth 2.0 to Access Google\n APIs](https://developers.google.com/identity/protocols/OAuth2).\n\n The default scopes are:\n - `https://www.googleapis.com/auth/spanner`\n - `https://www.googleapis.com/auth/spanner.data`\n- **timeout** (Integer) *(defaults to: nil)* --- Default timeout to use in requests. Optional.\n- **lib_name** (String) *(defaults to: nil)* --- Library name. This will be added as a prefix to the API call tracking header `x-goog-api-client` with provided lib version for telemetry. Optional. For example prefix looks like `spanner-activerecord/0.0.1 gccl/1.13.1`. Here, `spanner-activerecord/0.0.1` is provided custom library name and version and `gccl/1.13.1` represents the Cloud Spanner Ruby library with version.\n- **lib_version** (String) *(defaults to: nil)* --- Library version. This will be added as a prefix to the API call tracking header `x-goog-api-client` with provided lib name for telemetry. Optional. For example prefix look like `spanner-activerecord/0.0.1 gccl/1.13.1`. Here, `spanner-activerecord/0.0.1` is provided custom library name and version and `gccl/1.13.1` represents the Cloud Spanner Ruby library with version. \n**Returns**\n\n- ([Google::Cloud::Spanner::Project](./Google-Cloud-Spanner-Project))\n**Examples** \n\n```ruby\nrequire \"google/cloud\"\n\ngcloud = Google::Cloud.new\nspanner = gcloud.spanner\n```\n\nThe default scope can be overridden with the `scope` option: \n\n```ruby\nrequire \"google/cloud\"\n\ngcloud = Google::Cloud.new\nplatform_scope = \"https://www.googleapis.com/auth/cloud-platform\"\nspanner = gcloud.spanner scope: platform_scope\n```"]]