class_docstr: This handler handles connection and execution of the Cloud Spanner statements.
class_docstr_tok: ["This","handler","handles","connection","and","execution","of","the","Cloud","Spanner","statements","."]
docstr: Connect to a Cloud Spanner database.
  
  Returns:
      Connection: The database connection.
docstr_tok: ["Connect","to","a","Cloud","Spanner","database",".","Returns",":","Connection",":","The","database","connection","."]
code: def connect(self) -> Connection:
      """Connect to a Cloud Spanner database.
  
      Returns:
          Connection: The database connection.
      """
  
      if self.is_connected is True:
          return self.connection
  
      args = {
          "database_id": self.connection_data.get("database_id"),
          "instance_id": self.connection_data.get("instance_id"),
          "project": self.connection_data.get("project"),
          "credentials": self.connection_data.get("credentials"),
      }
  
      args[
          "credentials"
      ] = service_account.Credentials.from_service_account_info(
          json.loads(args["credentials"])
      )
      self.connection = spanner_dbapi.connect(**args)
      self.is_connected = True
  
      return self.connection
  
imports: import json
  from collections import OrderedDict
  from google.oauth2 import service_account
  from google.cloud import spanner_dbapi
  from google.cloud.spanner_dbapi import Connection
  from google.cloud.sqlalchemy_spanner import SpannerDialect
  import pandas
  from mindsdb_sql import parse_sql
  from mindsdb_sql.parser.ast.base import ASTNode
  from mindsdb_sql.parser.ast import CreateTable, Function
  from mindsdb_sql.render.sqlalchemy_render import SqlalchemyRender
  from mindsdb.integrations.libs.base import DatabaseHandler
  from mindsdb.integrations.libs.const import HANDLER_CONNECTION_ARG_TYPE
  from mindsdb.integrations.libs.response import RESPONSE_TYPE
  from mindsdb.integrations.libs.response import HandlerResponse
  from mindsdb.integrations.libs.response import HandlerStatusResponse
  from mindsdb.utilities import log
label_desc: Use image node_id 3 for calling the CloudSpannerHandler obj's underlying member method code with example usage: obj.connect() and returns: self, self