Class: Google::Cloud::Spanner::Snapshot
- Inherits:
 - 
      Object
      
        
- Object
 - Google::Cloud::Spanner::Snapshot
 
 
- Defined in:
 - lib/google/cloud/spanner/snapshot.rb
 
Overview
Snapshot
A snapshot in Cloud Spanner is a set of reads that execute atomically at a single logical point in time across columns, rows, and tables in a database.
Instance Method Summary collapse
- 
  
    
      #execute(sql, params: nil, types: nil)  ⇒ Google::Cloud::Spanner::Results 
    
    
      (also: #query)
    
  
  
  
  
  
  
  
  
  
    
Executes a SQL query.
 - 
  
    
      #range(beginning, ending, exclude_begin: false, exclude_end: false)  ⇒ Google::Cloud::Spanner::Range 
    
    
  
  
  
  
  
  
  
  
  
    
Creates a Cloud Spanner Range.
 - 
  
    
      #read(table, columns, keys: nil, index: nil, limit: nil)  ⇒ Google::Cloud::Spanner::Results 
    
    
  
  
  
  
  
  
  
  
  
    
Read rows from a database table, as a simple alternative to #execute.
 - 
  
    
      #timestamp  ⇒ Time 
    
    
  
  
  
  
  
  
  
  
  
    
The read timestamp chosen for snapshots.
 - 
  
    
      #transaction_id  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Identifier of the transaction results were run in.
 
Instance Method Details
#execute(sql, params: nil, types: nil) ⇒ Google::Cloud::Spanner::Results Also known as: query
Executes a SQL query.
Arguments can be passed using params, Ruby types are mapped to
Spanner types as follows:
| Spanner | Ruby | Notes | 
|---|---|---|
BOOL | 
true/false | 
|
INT64 | 
Integer | 
|
FLOAT64 | 
Float | 
|
STRING | 
String | 
|
DATE | 
Date | 
|
TIMESTAMP | 
Time, DateTime | 
|
BYTES | 
File, IO, StringIO, or similar | 
|
ARRAY | 
Array | 
Nested arrays are not supported. | 
See Data types.
      151 152 153 154 155  | 
    
      # File 'lib/google/cloud/spanner/snapshot.rb', line 151 def execute sql, params: nil, types: nil ensure_session! session.execute sql, params: params, types: types, transaction: tx_selector end  | 
  
#range(beginning, ending, exclude_begin: false, exclude_end: false) ⇒ Google::Cloud::Spanner::Range
Creates a Cloud Spanner Range. This can be used in place of a Ruby Range when needing to exclude the beginning value.
      227 228 229 230 231  | 
    
      # File 'lib/google/cloud/spanner/snapshot.rb', line 227 def range beginning, ending, exclude_begin: false, exclude_end: false Range.new beginning, ending, exclude_begin: exclude_begin, exclude_end: exclude_end end  | 
  
#read(table, columns, keys: nil, index: nil, limit: nil) ⇒ Google::Cloud::Spanner::Results
Read rows from a database table, as a simple alternative to #execute.
      192 193 194 195 196  | 
    
      # File 'lib/google/cloud/spanner/snapshot.rb', line 192 def read table, columns, keys: nil, index: nil, limit: nil ensure_session! session.read table, columns, keys: keys, index: index, limit: limit, transaction: tx_selector end  | 
  
#timestamp ⇒ Time
The read timestamp chosen for snapshots.
      57 58 59 60  | 
    
      # File 'lib/google/cloud/spanner/snapshot.rb', line 57 def return nil if @grpc.nil? Convert. @grpc. end  | 
  
#transaction_id ⇒ String
Identifier of the transaction results were run in.
      49 50 51 52  | 
    
      # File 'lib/google/cloud/spanner/snapshot.rb', line 49 def transaction_id return nil if @grpc.nil? @grpc.id end  |