PLZ hinzugefügt

This commit is contained in:
2024-12-05 16:53:16 +01:00
parent 50720596c6
commit 5865b33c1d
9 changed files with 1903 additions and 264 deletions

View File

@@ -1,5 +1,7 @@
from .DbManager import DbManager
import json
import mariadb
import time
class BusinessDAO:
def __init__(self):
@@ -11,5 +13,46 @@ class BusinessDAO:
self.__all_cols = [desc[0] for desc in self.__cur.description]
return self.__cur.fetchall(), self.__all_cols
def addBusiness(self):
pass
def addBusiness(self, data):
try:
print(data)
self.__cur.callproc("addBusiness", (json.dumps(data),))
self.__con.commit()
print(self.__cur.fetchall())
except mariadb.Error as e:
print(str(e))
def addPlz(self):
count = 1
with open("/home/dstoppek/Downloads/georef-germany-postleitzahl.json", "r") as plz:
postcodes = json.load(plz)
try:
for i in postcodes:
test =i["plz_name"].split(",")
for town in test:
if "u.a" in town:
town = town[:-4]
town = town.strip()
if town:
print(f"PROCESSING {i['name']} {town}")
self.__cur.callproc("addZipCodes", (i["name"], town,))
#time.sleep(1)
# self.__cur.execute(f"INSERT INTO postcode(postcode, addressid) VALUE ({i["name"]}, {count})")
# count += 1
except mariadb.OperationalError as e:
print(f"Database Error: {e}")
finally:
self.__con.commit()
print("FINISHED")

View File

@@ -75,17 +75,17 @@ class BusinessModel(QAbstractTableModel):
return len (self.__data)
def columnCount(self, parent= QModelIndex()):
return len(self.__visible_columns)
return len(self.__visible_columns) - 1
def data(self, index, role= Qt.DisplayRole):
if role == Qt.DisplayRole:
row = self.__data[index.row()]
return row[index.column()]
return row[index.column() + 1]
return None
def headerData(self, section, orientation, role= Qt.DisplayRole):
if orientation == Qt.Horizontal and role ==Qt.DisplayRole:
self.__col_name = self.__visible_columns[section]
self.__col_name = self.__visible_columns[section + 1]
return self.__col_name
return super().headerData(section, orientation, role)
@@ -108,7 +108,15 @@ class BusinessModel(QAbstractTableModel):
@Slot(dict)
def addBusiness(self, business):
# BusinessDAO().addBusiness(business)
BusinessDAO().addPlz()
@Slot(dict)
def setContact(self, contact):
pass
def updateTable(self):
pass