Changeset 733 for trunk


Ignore:
Timestamp:
Feb 22, 2010, 9:21:23 PM (10 years ago)
Author:
Nick Burch
Message:

Don't re-import previously deleted entries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/scripts/generic-python-import/generic_importer.py

    r705 r733  
    192192
    193193
    194                 # Grab all of the current ones
    195                 sql = "SELECT id, outward, inward, deleted FROM postcodes WHERE source = %s AND NOT deleted"
     194                # Grab all of the current ones, including deleted ones
     195                sql = "SELECT id, outward, inward, deleted FROM postcodes WHERE source = %s"
    196196                sth = dbh.cursor()
    197197                sth.execute(sql, source_id)
     
    215215                sth.close()
    216216
    217                 print "There are currently %d entries in the database from the %s. (Additionally, there are %d deleted ones)" % (count, self.source_name, deleted_count)
     217                print "There are currently %d entries in the database from the %s. (Additionally, there are %d deleted ones)" % (count-deleted_count, self.source_name, deleted_count)
    218218                print "The new import contains %d entries" % len(postcodes)
    219219
     
    252252
    253253                        if spcs.has_key(pc):
    254                                 # Update existing one
     254                                # If it's previously been deleted, just skip it
     255                                if spcs[pc]['deleted']:
     256                                        if self.verbose:
     257                                                print "\tSkipping as previously deleted (id %d)" % spcs[pc]['id']
     258                                        continue
     259
     260                                # Otherwise, update the existing entry
    255261                                spcs[pc]['done'] = True
    256262                                sth.execute(upd_sql, (postcode["outer"], postcode["inner"], postcode["raw_outer"], postcode["raw_inner"], postcode["easting"], postcode["northing"], postcode["ie_easting"], postcode["ie_northing"], spcs[pc]['id']))
Note: See TracChangeset for help on using the changeset viewer.