PLZ hinzugefügt
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user