Changeset 127
- Timestamp:
- Oct 22, 2006, 12:16:16 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/npemap.org.uk/scripts/freethepostcode.org-importer/importer.py
r83 r127 94 94 pc["inner"] = parts[3] 95 95 pc["raw"] = "%s %s" % (parts[2],parts[3]) 96 pc["raw_outer"] = parts[2] 97 pc["raw_inner"] = parts[3] 96 98 97 99 postcodes.append(pc) … … 108 110 print "There are currently %d entries in the database from freethepostcode.org" % count 109 111 print "The new import contains %d entries" % len(postcodes) 110 print "Are you sure you wish to remove the old entries, to add new ones?"111 confirm = raw_input("")112 print ""113 112 114 if confirm == "y" or confirm == "yes": 115 # Good, go ahead 116 p ass117 else: 113 # Only prompt if it's a big difference 114 if count == 0 or len(postcodes) == 0 or len(postcodes) < count or (len(postcodes)-count) > 50: 115 print "Are you sure you wish to remove the old entries, to add new ones?" 116 confirm = raw_input("") 118 117 print "" 119 raise Exception("Aborting import") 118 119 if confirm == "y" or confirm == "yes": 120 # Good, go ahead 121 pass 122 else: 123 print "" 124 raise Exception("Aborting import") 120 125 121 126 … … 130 135 131 136 # Add the latest list to the database 132 sql = "INSERT INTO postcodes (outward, inward, raw_postcode , easting, northing, source) VALUES (%s, %s, %s, %s, %s, %s)"137 sql = "INSERT INTO postcodes (outward, inward, raw_postcode_outward, raw_postcode_inward, easting, northing, source) VALUES (%s, %s, %s, %s, %s, %s, %s)" 133 138 sth = dbh.cursor() 134 139 worked = 0 135 140 for postcode in postcodes: 136 sth.execute(sql, (postcode["outer"], postcode["inner"], postcode["raw "], postcode["easting"], postcode["northing"], ftp_source))141 sth.execute(sql, (postcode["outer"], postcode["inner"], postcode["raw_outer"], postcode["raw_inner"], postcode["easting"], postcode["northing"], ftp_source)) 137 142 worked = worked + sth.rowcount 138 143 print "Added %d entries" % worked
Note: See TracChangeset
for help on using the changeset viewer.