示例#1
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    """
        session = database_sessions.Create(args.instance, args.database)
        try:
            return database_sessions.ExecuteSql(session, args.sql)
        finally:
            database_sessions.Delete(session)
示例#2
0
  def Run(self, args):
    """Runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    """
    session = CreateSession(args)
    try:
      return database_sessions.ExecuteSql(session, args.sql, args.query_mode)
    finally:
      database_sessions.Delete(session)
示例#3
0
  def Run(self, args):
    """Runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    """
    session = database_sessions.Create(args.instance, args.database)
    # Session id would be the string after the last /.
    session_id = session.name.split('/')[-1]
    try:
      return database_sessions.ExecuteSql(session, args.sql, args.query_mode)
    finally:
      database_sessions.Delete(args.instance, args.database, session_id)
示例#4
0
  def Run(self, args):
    """Runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    """
    session_name = database_sessions.Create(args.CONCEPTS.database.Parse())
    session = resources.REGISTRY.ParseRelativeName(
        relative_name=session_name.name,
        collection='spanner.projects.instances.databases.sessions')
    try:
      return database_sessions.ExecuteSql(session, args.sql, args.query_mode)
    finally:
      database_sessions.Delete(session)
示例#5
0
    def Run(self, args):
        """Runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    """
        read_only_options = self.ParseReadOnlyOptions(args)
        session = CreateSession(args)
        try:
            return database_sessions.ExecuteSql(args.sql, args.query_mode,
                                                session, read_only_options,
                                                args.enable_partitioned_dml,
                                                args.timeout)
        finally:
            database_sessions.Delete(session)