DEFAULT_BREED = 261 # default to dsh DATE_FORMAT = "MDY" # Normally MDY USE_SMDB_ENTRY_TYPE = False # If False, maps to new db defaults, if True looks up animal type and entry reason in target db START_ID = 100 animals = [] animaltests = [] animalmedicals = [] animalvaccinations = [] owners = [] movements = [] ppa = {} ppo = {} asm.setid("adoption", START_ID) asm.setid("animal", START_ID) asm.setid("animaltest", START_ID) asm.setid("animalmedical", START_ID) asm.setid("animalmedicaltreatment", START_ID) asm.setid("animalvaccination", START_ID) asm.setid("owner", START_ID) asm.setid("ownerdonation", START_ID) asm.setid("testtype", START_ID) asm.setid("vaccinationtype", START_ID) def getdate(s): if DATE_FORMAT == "DMY": return asm.getdate_ddmmyyyy(s) else:
bits = s.split(",") try: return bits[x] except: return "" owners = [] movements = [] animals = [] animalvaccinations = [] ppa = {} ppo = {} asm.setid("adoption", START_ID) asm.setid("animal", START_ID) asm.setid("owner", START_ID) asm.setid("animalvaccination", START_ID) asm.setid("internallocation", 2) # Remove existing print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM internallocation WHERE ID >= 2;" print "DELETE FROM adoption WHERE ID >= %d AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM animal WHERE ID >= %d AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM owner WHERE ID >= %d AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM animalvaccination WHERE ID >= %d AND CreatedBy = 'conversion';" % START_ID # Create a transfer owner to = asm.Owner()
9th March, 2016 - 27th April, 2016 """ PATH = "data/petwhere_tg1077" owners = [] ownerlicence = [] ownerdonation = [] animals = [] animalcontrol = [] animalcontrolanimal = [] ppa = {} ppo = {} asm.setid("animal", 100) asm.setid("owner", 100) asm.setid("ownerlicence", 100) asm.setid("ownerdonation", 100) asm.setid("animalcontrol", 100) print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= 100;" print "DELETE FROM animalcontrol WHERE ID >= 100;" print "DELETE FROM owner WHERE ID >= 100;" print "DELETE FROM ownerlicence WHERE ID >= 100;" print "DELETE FROM ownerdonation WHERE ID >= 100;" # pre-load address and residences mappings addresses = {} for a in DBF("%s/ADDRESS.DBF" % PATH):
if period == "MONTHS": d = asm.subtract_days(d, 31 * asm.cfloat(age)) if period == "WEEKS": d = asm.subtract_days(d, 7 * asm.cfloat(age)) return d owners = [] movements = [] animals = [] animalvaccinations = [] ppa = {} ppo = {} asm.setid("animal", 100) asm.setid("animalvaccination", 100) asm.setid("owner", 100) asm.setid("adoption", 100) # Remove existing print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= 100;" print "DELETE FROM animalvaccination WHERE ID >= 100;" print "DELETE FROM owner WHERE ID >= 100;" print "DELETE FROM adoption WHERE ID >= 100;" # Load up data files cowner = asm.csv_to_list("%s/tblOwnerDetails.csv" % PATH) canimal = asm.csv_to_list("%s/tblPetDetails.csv" % PATH) csurr = asm.csv_to_list("%s/tblSurrenderDetails.csv" % PATH)
ownermapbykey = {} ownermapbymasterid = {} animalmap = {} nextanimalid = 100 nextanimalcontrolid = 100 nextownerid = 100 nextownerdonationid = 100 nextmovementid = 100 startanimalid = 100 startanimalcontrolid = 100 startownerdonationid = 100 startownerid = 100 startmovementid = 100 asm.setid("donationtype", 100) unknown = asm.Owner(nextownerid) owners.append(unknown) nextownerid += 1 unknown.OwnerSurname = "Unknown" unknown.OwnerName = unknown.OwnerSurname MASTERID = 0 LASTNAME = 1 FIRSTNAME = 2 PHONENUMB = 3 BPHONE = 4 FAXNO = 5 EMAIL = 6 TITLE = 7
o.OwnerName = s return o # --- START OF CONVERSION --- owners = [] ownerdonations = [] movements = [] animals = [] animalvaccinations = [] logs = [] ppa = {} ppo = {} asm.setid("animal", START_ID) asm.setid("animalvaccination", START_ID) asm.setid("log", START_ID) asm.setid("owner", START_ID) asm.setid("ownerdonation", START_ID) asm.setid("adoption", START_ID) print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= %s;" % START_ID print "DELETE FROM animalvaccination WHERE ID >= %s;" % START_ID print "DELETE FROM owner WHERE ID >= %s;" % START_ID print "DELETE FROM ownerdonation WHERE ID >= %s;" % START_ID print "DELETE FROM adoption WHERE ID >= %s;" % START_ID # Create an unknown owner uo = asm.Owner()
def getdate(d): if d.find("?") != -1: return None return asm.getdate_guess(d) PATH = "/home/robin/tmp/asm3_import_data/db2007_csv/" # --- START OF CONVERSION --- animals = [] movements = [] owners = [] ownerlicences = [] ppo = {} asm.setid("adoption", 100) asm.setid("animal", 100) asm.setid("owner", 100) asm.setid("ownerlicence", 100) print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= 100 AND CreatedBy = 'conversion';" print "DELETE FROM adoption WHERE ID >= 100 AND CreatedBy = 'conversion';" print "DELETE FROM owner WHERE ID >= 100 AND CreatedBy = 'conversion';" print "DELETE FROM ownerlicence WHERE ID >= 100 AND CreatedBy = 'conversion';" # Create an unknown owner uo = asm.Owner() owners.append(uo) uo.OwnerSurname = "Unknown Owner" uo.OwnerName = uo.OwnerSurname
if s == "N": return 1 if s == "U": return 2 owners = [] ownerlicences = [] movements = [] animals = [] animalvaccinations = [] animalcontrol = [] animalcontrolanimals = [] ppa = {} ppo = {} asm.setid("adoption", START_ID) asm.setid("animal", START_ID) asm.setid("owner", START_ID) asm.setid("ownerlicence", START_ID) asm.setid("animalcontrol", START_ID) asm.setid("animalvaccination", START_ID) # Remove existing print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM adoption WHERE ID >= %d AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM animal WHERE ID >= %d AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM animalcontrol WHERE ID >= %d AND LastChangedBy = 'conversion';" % START_ID print "DELETE FROM animalcontrolanimal WHERE AnimalID IN " \ "(SELECT ID FROM animalcontrol WHERE ID >= %d AND LastChangedBy = 'conversion');" % START_ID print "DELETE FROM owner WHERE ID >= %d AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM ownerlicence WHERE ID >= %d AND CreatedBy = 'conversion';" % START_ID
# --- START OF CONVERSION --- # The shelter's petfinder ID for grabbing animal images for adoptable animals PETFINDER_ID = "CO145" pf = "" if PETFINDER_ID != "": pf = asm.petfinder_get_adoptable(PETFINDER_ID) owners = {} movements = [] animals = {} ownerdonations = [] animalvaccinations = [] asm.setid("animal", 100) asm.setid("animalvaccination", 100) asm.setid("owner", 100) asm.setid("ownerdonation", 100) asm.setid("adoption", 100) asm.setid("media", 100) asm.setid("dbfs", 300) print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= 100;" print "DELETE FROM media WHERE ID >= 100;" print "DELETE FROM dbfs WHERE ID >= 200;" print "DELETE FROM owner WHERE ID >= 100;" print "DELETE FROM ownerdonation WHERE ID >= 100;" print "DELETE FROM animalvaccination WHERE ID >= 100;" print "DELETE FROM adoption WHERE ID >= 100;"
o.OwnerAddress = address o.OwnerTown = city o.OwnerCounty = state o.OwnerPostcode = postal return o # --- START OF CONVERSION --- print "\\set ON_ERROR_STOP\nBEGIN;" owners = [] ownerdonations = [] donationtypes = [] ppo = {} ppt = {} asm.setid("owner", 100) asm.setid("ownerdonation", 100) asm.setid("donationtype", 100) print "DELETE FROM owner WHERE ID >= 100;" print "DELETE FROM ownerdonation WHERE ID >= 100;" print "DELETE FROM donationtype WHERE ID >= 100;" # customers.csv for row in asm.csv_to_list(PATH + "customers.csv"): if ppo.has_key(row["id"]): continue o = asm.Owner() owners.append(o) ppo[row["id"]] = o o.OwnerForeNames = row["First"] o.OwnerSurname = row["Last"]
d = asm.subtract_days(d, 365 * asm.cfloat(age)) if period == "MONTHS": d = asm.subtract_days(d, 31 * asm.cfloat(age)) if period == "WEEKS": d = asm.subtract_days(d, 7 * asm.cfloat(age)) return d owners = [] movements = [] animals = [] animalvaccinations = [] ppa = {} ppo = {} asm.setid("animal", 100) asm.setid("animalvaccination", 100) asm.setid("owner", 100) asm.setid("adoption", 100) # Remove existing print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= 100;" print "DELETE FROM animalvaccination WHERE ID >= 100;" print "DELETE FROM owner WHERE ID >= 100;" print "DELETE FROM adoption WHERE ID >= 100;" # Load up data files cowner = asm.csv_to_list("%s/tblOwnerDetails.csv" % PATH) canimal = asm.csv_to_list("%s/tblPetDetails.csv" % PATH) csurr = asm.csv_to_list("%s/tblSurrenderDetails.csv" % PATH)
owners = [] ownerlicences = [] logs = [] movements = [] animals = [] animalcontrol = [] animalcontrolanimals = [] animalvaccinations = [] ppa = {} ppo = {} ppac = {} addresses = {} addrlink = {} asm.setid("animal", 50000) asm.setid("animalcontrol", 50000) asm.setid("animalmedical", 50000) asm.setid("animalmedicaltreatment", 50000) asm.setid("animalvaccination", 50000) asm.setid("log", 50000) asm.setid("owner", 50000) asm.setid("ownerlicence", 50000) asm.setid("adoption", 50000) asm.setid("media", 50000) asm.setid("dbfs", 50000) # Remove existing print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM additional WHERE LinkID >= 50000;" print "DELETE FROM animal WHERE ID >= 50000;"
return datetime.date(year, int(b[1]), int(b[2])) except: return datetime.date(int(defyear) + 2000, 1, 1) def tocurrency(s): if s.strip() == "": return 0.0 s = s.replace("$", "") try: return float(s) except: return 0.0 # --- START OF CONVERSION --- # Starting IDs asm.setid("animal", 128) asm.setid("adoption", 36) asm.setid("owner", 11) # Create a single owner for all movements o = asm.Owner() o.OwnerName = "Owner" print o # List of codes we've seen to animals so far - if we already # have an animal we can add movements to it codes = {} # Readable references to CSV columns in the file CODE = 0
PATH = "/home/robin/tmp/asm3_import_data/barrk_rh2756" DEFAULT_BREED = 442 # default to mixed breed START_ID = 100 FETCH_MEDIA = False animals = [] animalmedicals = [] owners = [] movements = [] ppa = {} ppo = {} ppon = {} # lookup for owner via name instead of id asm.setid("adoption", START_ID) asm.setid("animal", START_ID) asm.setid("animalmedical", START_ID) asm.setid("animalmedicaltreatment", START_ID) asm.setid("owner", START_ID) asm.setid("media", START_ID) asm.setid("dbfs", START_ID) def getdate(s): return asm.getdate_iso(s) print("\\set ON_ERROR_STOP\nBEGIN;") print("DELETE FROM adoption WHERE ID >= %s;" % START_ID) print("DELETE FROM animal WHERE ID >= %s;" % START_ID)
o.OwnerTown = city o.OwnerCounty = state o.OwnerPostcode = postal return o # --- START OF CONVERSION --- print "\\set ON_ERROR_STOP\nBEGIN;" owners = [] ownerdonations = [] donationtypes = [] ppo = {} ppt = {} asm.setid("owner", 100) asm.setid("ownerdonation", 100) asm.setid("donationtype", 100) print "DELETE FROM owner WHERE ID >= 100;" print "DELETE FROM ownerdonation WHERE ID >= 100;" print "DELETE FROM donationtype WHERE ID >= 100;" # customers.csv for row in asm.csv_to_list(PATH + "customers.csv"): if ppo.has_key(row["id"]): continue o = asm.Owner() owners.append(o) ppo[row["id"]] = o o.OwnerForeNames = row["First"] o.OwnerSurname = row["Last"]
4th Jan, 2022 """ PATH = "/home/robin/tmp/asm3_import_data/petpal_dg2748.csv" # The shelter's petfinder ID for grabbing animal images for adoptable animals PETFINDER_ID = "" # --- START OF CONVERSION --- owners = [] movements = [] animals = [] asm.setid("animal", 100) asm.setid("owner", 100) asm.setid("adoption", 100) print("\\set ON_ERROR_STOP\nBEGIN;") print("DELETE FROM animal WHERE ID >= 100 AND CreatedBy LIKE '%conversion';") print("DELETE FROM owner WHERE ID >= 100 AND CreatedBy = 'conversion';") print("DELETE FROM adoption WHERE ID >= 100 AND CreatedBy = 'conversion';") pf = "" if PETFINDER_ID != "": asm.setid("media", 100) asm.setid("dbfs", 200) print("DELETE FROM media WHERE ID >= 100;") print("DELETE FROM dbfs WHERE ID >= 200;") pf = asm.petfinder_get_adoptable(PETFINDER_ID)
return s def size_id_for_name(name): if name.startswith("Very"): return 0 if name.startswith("Large"): return 1 if name.startswith("Medium"): return 2 if name.startswith("Small"): return 3 return 2 asm.setid("animal", START_ID) asm.setid("media", START_ID) asm.setid("dbfs", START_ID) asm.setid("owner", START_ID) asm.setid("adoption", START_ID) print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM owner WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM adoption WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM media WHERE ID >= %s;" % START_ID print "DELETE FROM dbfs WHERE ID >= %s;" % START_ID # Create an unknown owner uo = asm.Owner() owners.append(uo)
if age == "PUPPY": d = d - datetime.timedelta(days = 60) return d owners = [] ownerlicences = [] movements = [] animals = [] animalvaccinations = [] ppa = {} ppo = {} addresses = {} addrlink = {} asm.setid("animal", 300) asm.setid("animalvaccination", 300) asm.setid("owner", 300) asm.setid("ownerlicence", 300) asm.setid("adoption", 300) #asm.setid("media", 300) #asm.setid("dbfs", 300) # Remove existing print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= 300;" print "DELETE FROM animalvaccination WHERE ID >= 300;" print "DELETE FROM owner WHERE ID >= 300;" print "DELETE FROM ownerlicence WHERE ID >= 300;" print "DELETE FROM adoption WHERE ID >= 300;" #print "DELETE FROM media WHERE ID >= 300;"
if s.find(k) != -1: return v return 11 # --- START OF CONVERSION --- print "\\set ON_ERROR_STOP\nBEGIN;" animals = [] animalvaccinations = [] owners = [] ownerdonations = [] ppo = {} ppa = {} movements = [] asm.setid("adoption", 100) asm.setid("animal", 100) asm.setid("animalmedical", 100) asm.setid("animalmedicaltreatment", 100) asm.setid("animalvaccination", 100) asm.setid("owner", 100) asm.setid("ownerdonation", 100) print "DELETE FROM adoption WHERE ID >= 100;" print "DELETE FROM animal WHERE ID >= 100;" print "DELETE FROM animalmedical WHERE ID >= 100;" print "DELETE FROM animalmedicaltreatment WHERE ID >= 100;" print "DELETE FROM animalvaccination WHERE ID >= 100;" print "DELETE FROM owner WHERE ID >= 100;" print "DELETE FROM ownerdonation WHERE ID >= 100;" print "DELETE FROM vaccinationtype;"
vacctype = {} medtype = {} animalnotes = {} users = {} owners = [] ownerdonations = [] documents = {} ppo = {} ppa = {} movements = [] animals = [] animalmedicals = [] animalvaccinations = [] asm.setid("animal", 100) asm.setid("dbfs", 400) asm.setid("media", 100) asm.setid("owner", 100) asm.setid("ownerdonation", 100) asm.setid("adoption", 100) asm.setid("animalvaccination", 100) asm.setid("animalmedical", 100) asm.setid("animalmedicaltreatment", 100) print "DELETE FROM animal WHERE ID >= 100;" print "DELETE FROM animalvaccination WHERE ID >= 100;" print "DELETE FROM animalmedical WHERE ID >= 100;" print "DELETE FROM animalmedicaltreatment WHERE ID >= 100;" print "DELETE FROM dbfs WHERE ID >= 100;" print "DELETE FROM media WHERE ID >= 100;"
ownerdonations = [] ownerlicences = [] movements = [] logs = [] animals = [] animalcontrol = [] ppa = {} ppo = {} arkspecies = { "C": 1, # Dog "F": 2, # Cat "E": 24 # Horse } asm.setid("animal", START_ID) asm.setid("owner", START_ID) asm.setid("ownerdonation", START_ID) asm.setid("ownerlicence", START_ID) asm.setid("adoption", START_ID) asm.setid("animalcontrol", START_ID) asm.setid("log", START_ID) print("\\set ON_ERROR_STOP\nBEGIN;") print("DELETE FROM animal WHERE ID >= %s;" % START_ID) print("DELETE FROM animalcontrol WHERE ID >= %s;" % START_ID) print("DELETE FROM owner WHERE ID >= %s;" % START_ID) print("DELETE FROM ownerdonation WHERE ID >= %s;" % START_ID) print("DELETE FROM ownerlicence WHERE ID >= %s;" % START_ID) print("DELETE FROM adoption WHERE ID >= %s;" % START_ID) print("DELETE FROM log WHERE ID >= %s;" % START_ID)
def psYesNoUnknown(v): """ Translates a ps value of Yes, No or Not Sure into our yes no unknown integers """ if v.lower() == "yes": return 0 elif v.lower() == "no": return 1 else: return 2 # --- START OF CONVERSION --- owners = [] movements = [] animals = [] ppa = {} ppo = {} asm.setid("animal", START_ID) asm.setid("owner", START_ID) asm.setid("adoption", START_ID) print("\\set ON_ERROR_STOP\nBEGIN;") print("DELETE FROM animal WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID) print("DELETE FROM owner WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID) print("DELETE FROM adoption WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID) # Create an unknown owner uo = asm.Owner() owners.append(uo) uo.OwnerSurname = "Unknown Owner" uo.OwnerName = uo.OwnerSurname # Sort the data on intake date ascending
logs = [] movements = [] animals = [] animalmedicals = [] animalcontrol = [] animalcontrolanimals = [] animalvaccinations = [] ppa = {} ppo = {} ppac = {} intakes = { } # map of tblAnimalsID -> tblAnimalIntakesDisposition row for speed processing large tblAnimals asm.setid("animal", START_ID) asm.setid("animalcontrol", START_ID) asm.setid("animalmedical", START_ID) asm.setid("animalmedicaltreatment", START_ID) asm.setid("animalvaccination", START_ID) asm.setid("log", START_ID) asm.setid("owner", START_ID) asm.setid("ownerlicence", START_ID) asm.setid("adoption", START_ID) asm.setid("media", START_ID) asm.setid("dbfs", START_ID) # Remove existing print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM additional WHERE LinkID >= %d;" % START_ID print "DELETE FROM animal WHERE ID >= %d;" % START_ID
owners = [] ownerdonations = [] ownerlicences = [] movements = [] animals = [] animalcontrol = [] ppa = {} ppo = {} arkspecies = { "C": 1, # Dog "F": 2, # Cat "E": 24 # Horse } asm.setid("animal", 100) asm.setid("owner", 100) asm.setid("ownerdonation", 100) asm.setid("ownerlicence", 100) asm.setid("adoption", 100) asm.setid("animalcontrol", 100) print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= 100;" print "DELETE FROM animalcontrol WHERE ID >= 100;" print "DELETE FROM owner WHERE ID >= 100;" print "DELETE FROM ownerdonation WHERE ID >= 100;" print "DELETE FROM ownerlicence WHERE ID >= 100;" print "DELETE FROM adoption WHERE ID >= 100;" for p in DBF("%s/NAMES.DBF" % PATH):
1st September, 2020 """ PATH = "/home/robin/tmp/asm3_import_data/kb1851_csv" START_ID = 2000 owners = [] ownerlicence = [] ownerdonation = [] animals = [] animalcontrol = [] animalcontrolanimal = [] ppa = {} ppo = {} asm.setid("animal", START_ID) asm.setid("owner", START_ID) asm.setid("ownerlicence", START_ID) asm.setid("animalcontrol", START_ID) print("\\set ON_ERROR_STOP\nBEGIN;") print("DELETE FROM animal WHERE ID >= %s AND CreatedBy LIKE 'conversion%%';" % START_ID) print( "DELETE FROM animalcontrol WHERE ID >= %s AND CreatedBy LIKE 'conversion%%';" % START_ID) print("DELETE FROM owner WHERE ID >= %s AND CreatedBy LIKE 'conversion%%';" % START_ID) print( "DELETE FROM ownerlicence WHERE ID >= %s AND CreatedBy LIKE 'conversion%%';" % START_ID)
return 3 return 2 def getdate(s): return asm.getdate_mmddyy(s) # --- START OF CONVERSION --- print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= 100 AND CreatedBy = 'conversion';" print "DELETE FROM owner WHERE ID >= 100 AND CreatedBy = 'conversion';" print "DELETE FROM adoption WHERE ID >= 100 AND CreatedBy = 'conversion';" print "DELETE FROM animalvaccination WHERE ID >= 100 AND CreatedBy = 'conversion';" print "DELETE FROM animalmedical WHERE ID >= 100 AND CreatedBy = 'conversion';" print "DELETE FROM animalmedicaltreatment WHERE ID >= 100 AND CreatedBy = 'conversion';" asm.setid("animal", 100) asm.setid("animalmedical", 100) asm.setid("animalmedicaltreatment", 100) asm.setid("animalvaccination", 100) asm.setid("owner", 100) asm.setid("adoption", 100) owners = [] movements = [] animals = [] animalvaccinations = [] animalmedicals = [] # List of trackids we've seen for animals so far ppa = {}
def note_fix(s): return s.encode("ascii", "xmlcharrefreplace") # --- START OF CONVERSION --- owners = [] ownerdonations = [] movements = [] animals = [] logs = [] ppa = {} ppo = {} asm.setid("animal", 100) asm.setid("log", 100) asm.setid("owner", 100) asm.setid("ownerdonation", 100) asm.setid("adoption", 100) print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM internallocation;" print "DELETE FROM animal WHERE ID >= 100;" print "DELETE FROM owner WHERE ID >= 100;" print "DELETE FROM ownerdonation WHERE ID >= 100;" print "DELETE FROM adoption WHERE ID >= 100;" # Deal with people first for d in db.select("members").list(): # Each row contains a person
ownerlicences = [] logs = [] movements = [] animals = [] animalvaccinations = [] animalcontrol = [] animalcontrolanimals = [] ppa = {} ppo = {} ppi = {} addresses = {} addrlink = {} notes = {} asm.setid("adoption", START_ID) asm.setid("animal", START_ID) asm.setid("animalcontrol", START_ID) asm.setid("log", START_ID) asm.setid("owner", START_ID) if VACCINATION_IMPORT: asm.setid("animalvaccination", START_ID) if LICENCE_IMPORT: asm.setid("ownerlicence", START_ID) if PICTURE_IMPORT: asm.setid("media", START_ID) if PICTURE_IMPORT: asm.setid("dbfs", START_ID) # Remove existing print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM adoption WHERE ID >= %d AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM animal WHERE ID >= %d AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM owner WHERE ID >= %d AND CreatedBy = 'conversion';" % START_ID
if age == "PUPPY": d = d - datetime.timedelta(days = 60) return d owners = [] ownerlicences = [] movements = [] animals = [] animalvaccinations = [] ppa = {} ppo = {} addresses = {} addrlink = {} asm.setid("animal", 100) asm.setid("animalvaccination", 100) asm.setid("owner", 100) asm.setid("ownerlicence", 100) asm.setid("adoption", 100) asm.setid("media", 100) asm.setid("dbfs", 300) # Remove existing print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= 100;" print "DELETE FROM animalvaccination WHERE ID >= 100;" print "DELETE FROM owner WHERE ID >= 100;" print "DELETE FROM ownerlicence WHERE ID >= 100;" print "DELETE FROM adoption WHERE ID >= 100;" print "DELETE FROM media WHERE ID >= 100;"
return rv # --- START OF CONVERSION --- owners = [] movements = [] animals = [] animalcontrol = [] animaltests = [] animalvaccinations = [] logs = [] ppa = {} ppo = {} asm.setid("animal", START_ID) asm.setid("animalcontrol", START_ID) asm.setid("animaltest", START_ID) asm.setid("animalvaccination", START_ID) asm.setid("log", START_ID) asm.setid("owner", START_ID) asm.setid("adoption", START_ID) print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM internallocation;" print "DELETE FROM animal WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM animalcontrol WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM animaltest WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM animalvaccination WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM log WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM owner WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID
ownermapbykey = {} ownermapbymasterid = {} animalmap = {} nextanimalid = 100 nextanimalcontrolid = 100 nextownerid = 100 nextownerdonationid = 100 nextmovementid = 100 startanimalid = 100 startanimalcontrolid = 100 startownerdonationid = 100 startownerid = 100 startmovementid = 100 asm.setid("donationtype", 100) unknown = asm.Owner(nextownerid) owners.append(unknown) nextownerid += 1 unknown.OwnerSurname = "Unknown" unknown.OwnerName = unknown.OwnerSurname for row in asm.csv_to_list(PATH + "list1.csv", strip=True): o = asm.Owner(nextownerid) owners.append(o) nextownerid += 1 o.ExtraID = row["MasterID"] o.OwnerTitle = row["TITLE"] o.OwnerForeNames = row["FIRSTNAME"] o.OwnerSurname = row["LASTNAME"]
def getdate(d): return asm.getdate_mmddyy(d) # --- START OF CONVERSION --- owners = [] ownerdonations = [] movements = [] animals = [] animaltests = [] animalmedicals = [] animalvaccinations = [] logs = [] asm.setid("animal", START_ID) asm.setid("animalmedical", START_ID) asm.setid("animalmedicaltreatment", START_ID) asm.setid("animalvaccination", START_ID) asm.setid("log", START_ID) asm.setid("owner", START_ID) asm.setid("ownerdonation", START_ID) asm.setid("adoption", START_ID) print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= %s;" % START_ID print "DELETE FROM animalmedical WHERE ID >= %s;" % START_ID print "DELETE FROM animalmedicaltreatment WHERE ID >= %s;" % START_ID print "DELETE FROM animalvaccination WHERE ID >= %s;" % START_ID print "DELETE FROM log WHERE ID >= %s;" % START_ID print "DELETE FROM owner WHERE ID >= %s;" % START_ID
PICTURES = "/home/robin/tmp/asm3_import_data/rc_li2142/photos/final" def getdate(d, noblanks=False): rv = asm.getdate_guess(d) if noblanks and rv is None: rv = asm.now() return rv # --- START OF CONVERSION --- owners = [] movements = [] animals = [] asm.setid("animal", START_ID) asm.setid("owner", START_ID) asm.setid("adoption", START_ID) if PICTURE_IMPORT: asm.setid("media", START_ID) if PICTURE_IMPORT: asm.setid("dbfs", START_ID) print "\\set ON_ERROR_STOP\nBEGIN;" print "DELETE FROM animal WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM owner WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID print "DELETE FROM adoption WHERE ID >= %s AND CreatedBy = 'conversion';" % START_ID if PICTURE_IMPORT: print "DELETE FROM media WHERE ID >= %d;" % START_ID if PICTURE_IMPORT: print "DELETE FROM dbfs WHERE ID >= %d;" % START_ID # Create an unknown owner uo = asm.Owner() owners.append(uo)
# --- START OF CONVERSION --- print "\\set ON_ERROR_STOP\nBEGIN;" addresses = {} suburbs = {} vacctype = {} owners = [] documents = {} ppo = {} ppa = {} movements = [] animals = [] asm.setid("animal", 100) asm.setid("dbfs", 400) asm.setid("media", 100) asm.setid("owner", 100) asm.setid("ownerdonation", 100) asm.setid("adoption", 100) asm.setid("animalvaccination", 100) print "DELETE FROM animal WHERE ID >= 100;" print "DELETE FROM animalvaccination WHERE ID >= 100;" print "DELETE FROM dbfs WHERE ID >= 100;" print "DELETE FROM media WHERE ID >= 100;" print "DELETE FROM owner WHERE ID >= 100;" print "DELETE FROM ownerdonation WHERE ID >= 100;" print "DELETE FROM adoption WHERE ID >= 100;"
def tocurrency(s): if s.strip() == "": return 0.0 s = s.replace("$", "") try: return float(s) except: return 0.0 # --- START OF CONVERSION --- print "\\set ON_ERROR_STOP\nBEGIN;" # Starting IDs asm.setid("animal", 128) asm.setid("adoption", 36) asm.setid("owner", 11) # Create a single owner for all movements o = asm.Owner() o.OwnerName = "Owner" print o # List of codes we've seen to animals so far - if we already # have an animal we can add movements to it codes = {} # Readable references to CSV columns in the file CODE = 0 SPECIES = 1