Use ORM for applicants
This commit is contained in:
@@ -1,27 +1,26 @@
|
||||
from .DbManager import DbManager
|
||||
import mariadb
|
||||
import json
|
||||
|
||||
import mariadb
|
||||
|
||||
from lib.domain.BaseModel import database
|
||||
|
||||
|
||||
class AddressDAO:
|
||||
__cur = None
|
||||
|
||||
def __init__(self):
|
||||
#print(f"*** File: {__file__}, init()")
|
||||
self.__con = DbManager().getConnection()
|
||||
self.__con = database.connection()
|
||||
|
||||
if self.__con:
|
||||
self.__cur = self.__con.cursor()
|
||||
|
||||
|
||||
|
||||
|
||||
def __importPlz(self):
|
||||
with open("pfad zur datei", "r") as plz:
|
||||
postcodes = json.load(plz)
|
||||
irgendwas = ""
|
||||
try:
|
||||
for i in postcodes:
|
||||
test =i["plz_name"].split(",")
|
||||
test = i["plz_name"].split(",")
|
||||
for town in test:
|
||||
if "u.a" in town:
|
||||
town = town[:-4]
|
||||
@@ -29,12 +28,12 @@ class AddressDAO:
|
||||
if town:
|
||||
print(f"PROCESSING {i['name']} {town}")
|
||||
self.__cur.callproc("addZipCodes", (i["name"], town, irgendwas,))
|
||||
#self.__cur.callproc("addZipCodes", ("56271", "Kleinmaischeid", irgendwas,))
|
||||
# self.__cur.callproc("addZipCodes", ("56271", "Kleinmaischeid", irgendwas,))
|
||||
except mariadb.OperationalError as e:
|
||||
print(f"Database Error: {e}")
|
||||
finally:
|
||||
self.__con.commit()
|
||||
print("FINISHED")#
|
||||
print("FINISHED") #
|
||||
|
||||
def __importCountry(self):
|
||||
with open("pfad zur datei", "r") as country:
|
||||
@@ -55,18 +54,17 @@ class AddressDAO:
|
||||
|
||||
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]))
|
||||
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")#
|
||||
print("FINISHED") #
|
||||
|
||||
|
||||
|
||||
|
||||
def getAddressData(self, all = True, zipcode = None):
|
||||
def getAddressData(self, all=True, zipcode=None):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("getAddress", (all, zipcode,))
|
||||
@@ -76,5 +74,3 @@ class AddressDAO:
|
||||
return None
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user