Example #1
0
    def do_use(self, args):
        ''''''
        if args == "":
            self.help_use()
            return

        items = args.split()

        cluster_name = items[0]
           
        if cluster_name not in clusters:
            print "Cluster name {0} is not in this cluster list, please run 'list' for details.".format(cluster_name)
            return
           
        self.current_instance = clusters[cluster_name].slave

        if len(items) == 2 and items[1].lower() == "master":
            self.current_instance = clusters[cluster_name].master
         
        if self.current_connection is not None:
            conn.close_conn(self.current_connection)
        self.prompt = "{0}> ".format(self.current_instance.get_summary())


        self.current_connection = conn.get_conn(self.current_instance, self.user, self.pwd)
        self.cursor = self.current_connection.cursor()
Example #2
0
    def run_on_instance(self, instance, sql, autocommit=False):
        ''' '''
        cnx = conn.get_conn(instance, self.user, self.pwd)
        cursor = cnx.cursor()
        if autocommit:
            cursor.execute("set autocommit=1")

        cursor.execute(sql)
        rows = cursor.fetchall()
        columns = cursor.column_names
        cnx.close()

        return rows, columns