Beispiel #1
0
	def refresh(self):
		self.host.select_database(self)
		if self.host.is_at_least_version("4.1.1"):
			self.host.query("show variables like 'character_set_database'")
			result = self.handle.store_result()
			row = result.fetch_row()
			self.charset = row[0][1]
			print "using database charset %r" % (self.charset)
		else:
			self.charset = self.host.charset
			print "using server charset %r for this database" % (self.charset)
		if not self.host.query("show table status"): return
		new_tables = []
		
		result = self.handle.store_result()
		self.status_headers = []
		for h in result.describe():
			self.status_headers.append(h[0])
		old = dict(zip(self.tables.keys(), range(len(self.tables))))
		for row in result.fetch_row(0):
			if not row[0] in old:
				#print "new table", row[0]
				self.tables[row[0]] = mysql_table(self, row, result.describe())
				new_tables.append(row[0])
			else:
				#print "known table", row[0]
				# todo update self.tables[row[0]] with row!
				del old[row[0]]
				
		for table in old:
			print "destroy table", table
			del self.tables[table]
		return new_tables
Beispiel #2
0
    def refresh(self):
        self.host.select_database(self)
        if not self.host.query("show table status"):
            return
        new_tables = []

        result = self.handle.store_result()
        self.status_headers = []
        for h in result.describe():
            self.status_headers.append(h[0])
        old = dict(zip(self.tables.keys(), range(len(self.tables))))
        for row in result.fetch_row(0):
            if not row[0] in old:
                # print "new table", row[0]
                self.tables[row[0]] = mysql_table(self, row, result.describe())
                new_tables.append(row[0])
            else:
                # print "known table", row[0]
                # todo update self.tables[row[0]] with row!
                del old[row[0]]

        for table in old:
            print "destroy table", table
            del self.tables[table]
        return new_tables