Added importCountry

This commit is contained in:
2025-01-22 16:52:49 +01:00
parent 180f8e5ae9
commit c2edfab9a2
14 changed files with 17805 additions and 482 deletions

View File

@@ -8,10 +8,12 @@ class AddressDAO:
def __init__(self):
#print(f"*** File: {__file__}, init()")
self.__con = DbManager().getConnection()
if self.__con:
self.__cur = self.__con.cursor()
def __importPlz(self):
with open("import json filepath here", "r") as plz:
postcodes = json.load(plz)
@@ -31,6 +33,36 @@ class AddressDAO:
self.__con.commit()
print("FINISHED")#
def __importCountry(self):
with open("/home/dstoppek/Downloads/staaten.json", "r") as country:
countries = json.load(country)
old = ""
try:
for i in countries["daten"]:
if i[4] == "":
continue
elif i[8] == "YU":
continue
elif i[4] == old:
continue
elif i[4] == "Serbien und Montenegro":
continue
elif i[4] == "Bosnien und Herzegowina":
continue
print(i[4], i[3], i[2], i[8], i[7])
self.__cur.execute("INSERT INTO country (country, countryshort, nationality, iso2, iso3) VALUES (%s, %s, %s, %s, %s)", (i[4], i[3], i[2], i[8], i[7]))
old = i[4]
except mariadb.OperationalError as e:
print(f"Database Error: {e}")
finally:
self.__con.commit()
print("FINISHED")#
def getAddressData(self, all = True, zipcode = None):
try:
if self.__cur: