AddLocation
This commit is contained in:
2527
doc/.$datenbank.drawio.dtmp
Normal file
2527
doc/.$datenbank.drawio.dtmp
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1594
doc/db_schemer_v1.1-pyqcrm-202501210906.sql
Normal file
1594
doc/db_schemer_v1.1-pyqcrm-202501210906.sql
Normal file
File diff suppressed because it is too large
Load Diff
BIN
doc/pyqcrm_er_diagram.png
Normal file
BIN
doc/pyqcrm_er_diagram.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 325 KiB |
42
lib/AddCity.py
Normal file
42
lib/AddCity.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import json
|
||||
import mariadb
|
||||
from .DB.DbManager import DbManager
|
||||
|
||||
|
||||
|
||||
class AddCity:
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.__con = DbManager().getConnection()
|
||||
if self.__con:
|
||||
self.__cur = self.__con.cursor()
|
||||
|
||||
def addPlz(self):
|
||||
count = 1
|
||||
with open("/home/dstoppek/Downloads/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, count,))
|
||||
|
||||
|
||||
#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")
|
||||
|
||||
4
main.py
4
main.py
@@ -14,6 +14,8 @@ from lib.DB.AddressModel import AddressModel
|
||||
from lib.DB.BTypeModel import BTypeModel
|
||||
from lib.DB.ContactModel import ContactModel
|
||||
|
||||
from lib.AddCity import AddCity
|
||||
|
||||
|
||||
# [pyqcrm]
|
||||
# program-name=""
|
||||
@@ -87,7 +89,7 @@ if __name__ == "__main__":
|
||||
engine.rootContext().setContextProperty("config", config)
|
||||
|
||||
engine.load(qml_file)
|
||||
|
||||
#AddCity().addPlz()
|
||||
|
||||
if not engine.rootObjects():
|
||||
sys.exit(-1)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"lib/DB/BTypeModel.py",
|
||||
"lib/DB/BTypeDAO.py",
|
||||
"lib/DB/ContactDAO.py",
|
||||
"lib/DB/ContactModel.py"
|
||||
"lib/DB/ContactModel.py",
|
||||
"lib/AddCity.py"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user