From: olivier Date: Thu, 23 Apr 2009 18:48:22 +0000 (+0000) Subject: migration: print collections:copy stats X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=5d83ba65930c13035cf68a02605a1986b1bc58bf;p=telemeta-data.git migration: print collections:copy stats git-svn-id: http://svn.parisson.org/svn/crem@86 3bf09e05-f825-4182-b9bc-eedd7160adf0 --- diff --git a/trunk/import/migration/tasks/collections.py b/trunk/import/migration/tasks/collections.py index 2bc45e9..eff2b3b 100644 --- a/trunk/import/migration/tasks/collections.py +++ b/trunk/import/migration/tasks/collections.py @@ -86,6 +86,7 @@ class CollectionsCopyMigrator(DataMigrator): self.src_cursor.execute("SELECT COUNT(*) FROM %s.Support" % self.src_db_name) count = self.src_cursor.fetchone()[0] + self.stats = { 'total': count, 'imported': 0, 'ignored': 0} for offset in range(0, count): query = "INSERT INTO %s.media_collections (\n %s\n)\n" \ @@ -98,12 +99,14 @@ class CollectionsCopyMigrator(DataMigrator): try: self.target_cursor.execute(query) + self.stats['imported'] += 1 except IntegrityError, e: (errno, errmsg) = e if errno == DUP_ENTRY: self.src_cursor.execute("SELECT Cote FROM %s.Support LIMIT %d, 1" % (self.src_db_name, offset)) id = self.src_cursor.fetchone()[0] print "Collection %s not imported: %s" % (id, errmsg) + self.stats['ignored'] += 1 else: raise e @@ -163,6 +166,8 @@ class CollectionsEnumMigrator(DataMigrator): "WHERE code = %s", (idrow[0], code)) if self.target_cursor.rowcount > 1: raise Exception("Updated more than one row, this shouldn't happen..") + elif not self.target_cursor.rowcount: + print "Can't find migrated collection: %s" % code else: print "Can't find value '%s' in %s" % (value, enum_tables[i])