From f3dc0e71e6513a7ca2ee0fddc26b0851a10ef085 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 26 Jun 2010 16:38:20 -0400 Subject: [PATCH] Added logging commands to export_mysql --- sitecore/prof/export_mysql.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sitecore/prof/export_mysql.py b/sitecore/prof/export_mysql.py index 21a229c..1514c9e 100644 --- a/sitecore/prof/export_mysql.py +++ b/sitecore/prof/export_mysql.py @@ -45,6 +45,8 @@ class SimpleDB (object): username = getpass.getpass('username: ') if password == None: password = getpass.getpass('password: ') + self.logger.info('logging in to %s:%s as %s' + % (host, database, username)) self.db = MySQLdb.connect(host=host, user=username, passwd=password, db=database) del(username) @@ -52,9 +54,14 @@ class SimpleDB (object): self.cursor = self.db.cursor() def disconnect(self): + self.logger.info('disconnecting') self.cursor = None self.db.close() + def execute(self, command): + self.logger.info(command) + self.cursor.execute(command) + def set_default_table(self, table): self.table = table @@ -64,15 +71,15 @@ class SimpleDB (object): dict = self._clean_dict(dict) keys = dict.keys() values = ["'%s'" % dict[key] for key in keys] - self.cursor.execute("INSERT INTO %s (%s) VALUES (%s)" - % (table, ', '.join(keys), ', '.join(values))) + self.execute("INSERT INTO %s (%s) VALUES (%s)" + % (table, ', '.join(keys), ', '.join(values))) # error checking def list_entries(self, dict=None, table=None): if table == None: table = self.table where = self._where_string(dict) - self.cursor.execute('SELECT * FROM %s%s' % (table, where)) + self.execute('SELECT * FROM %s%s' % (table, where)) numrows = int(self.cursor.rowcount) print '\t'.join([dtuple[0] for dtuple in self.cursor.description]) for x in range(0,numrows): @@ -83,7 +90,7 @@ class SimpleDB (object): if table == None: table = self.table where = self._where_string(dict) - self.cursor.execute('DELETE FROM %s%s' % (table, where)) + self.execute('DELETE FROM %s%s' % (table, where)) def _clean_dict(self, dict=None): if dict == None: -- 2.26.2