aboutsummaryrefslogtreecommitdiffstats
path: root/update_db.py
diff options
context:
space:
mode:
Diffstat (limited to 'update_db.py')
-rw-r--r--update_db.py50
1 files changed, 41 insertions, 9 deletions
diff --git a/update_db.py b/update_db.py
index 3a9fba0..b85eb52 100644
--- a/update_db.py
+++ b/update_db.py
@@ -102,6 +102,8 @@ def find_other_properties(c, ICO, element, conn, primary_sql_key):
find_predmet_podnikani(c, ICO, elem2, conn, primary_sql_key, element)
elif udajTyp_name == "PREDMET_CINNOSTI_SEKCE":
find_predmet_cinnosti(c, ICO, elem2, conn, primary_sql_key, element)
+ elif udajTyp_name == "UCEL_SUBJEKTU_SEKCE":
+ find_ucel(c, ICO, elem2, conn, primary_sql_key, element)
elif udajTyp_name == "ZAKLADNI_KAPITAL":
find_zakladni_kapital(c, ICO, elem2, conn, primary_sql_key, element)
elif udajTyp_name == "OST_SKUTECNOSTI_SEKCE":
@@ -125,7 +127,7 @@ def find_registered_office(c, ICO, elem2, conn, primary_sql_key, element):
try:
zapis_datum = str(get_prop(elem2, ".//zapisDatum"))
vymaz_datum = str(get_prop(elem2, ".//vymazDatum"))
- sidlo_id = sidlo3(c, elem2, primary_sql_key)
+ sidlo_id = find_sidlo(c, elem2, primary_sql_key)
insert_instructions = [None,"adresy", "adresa_text", "sidlo_relation"]
insert_relation_information_v2(c, insert_instructions, primary_sql_key, sidlo_id, zapis_datum, vymaz_datum)
except Exception as f:
@@ -209,7 +211,7 @@ def find_spolecnik(c, ICO, elem2, conn, primary_sql_key, element):
# I probably do not need the primary sql key
spolecnik_fo_id = find_fyzicka_osoba(c, ICO, elem, conn, primary_sql_key, element)
# adresa_id = find_and_store_address(c, elem)
- adresa_id = sidlo3(c, elem, primary_sql_key)
+ adresa_id = find_sidlo(c, elem, primary_sql_key)
c.execute("INSERT INTO spolecnici (company_id, spolecnik_fo_id, zapis_datum, vymaz_datum, adresa_id, text_spolecnik) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, spolecnik_fo_id, zapis_datum, vymaz_datum, adresa_id, text_spolecnik,))
c.execute ("SELECT last_insert_rowid()")
spolecnik_id = c.fetchone()[0]
@@ -219,7 +221,7 @@ def find_spolecnik(c, ICO, elem2, conn, primary_sql_key, element):
regCislo = str(get_prop(elem, "osoba/regCislo"))
spolecnik_po_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo)
# adresa_id = find_and_store_address(c, elem)
- adresa_id = sidlo3(c, elem, primary_sql_key)
+ adresa_id = find_sidlo(c, elem, primary_sql_key)
c.execute("INSERT INTO spolecnici (company_id, spolecnik_po_id, zapis_datum, vymaz_datum, adresa_id, text_spolecnik) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, spolecnik_po_id, zapis_datum, vymaz_datum, adresa_id, text_spolecnik,))
c.execute ("SELECT last_insert_rowid()")
spolecnik_id = c.fetchone()[0]
@@ -261,6 +263,24 @@ def find_predmet_cinnosti(c, ICO, predmet_cinnosti_elem, conn, primary_sql_key,
except:
pass
+def find_ucel(c, ICO, ucel_elem, conn, primary_sql_key, element):
+ try:
+ my_iter = ucel_elem.findall("podudaje")
+ for elem in my_iter:
+ my_iter2 = elem.iter("Udaj")
+ for elem2 in my_iter2:
+ zapis_datum = str(get_prop(elem2, ".//zapisDatum"))
+ vymaz_datum = str(get_prop(elem2, ".//vymazDatum"))
+ insert_instructions = [(".//hodnotaText", "ucel", "ucel", "ucel_relation")]
+ for elem in insert_instructions:
+ inserted_figure = str(get_prop(elem2, ".//hodnotaText"))
+ insert_into_ancillary_table(c, elem, inserted_figure)
+ ancillary_table_key = get_anciallary_table_key(c, elem, inserted_figure)
+ insert_relation_information_v2(c, elem, primary_sql_key, ancillary_table_key, zapis_datum, vymaz_datum)
+ except Exception as f:
+ print(f)
+
+
def find_zakladni_kapital(c, ICO, elem2, conn, primary_sql_key, element):
try:
zapis_datum = str(get_prop(elem2, ".//zapisDatum"))
@@ -331,7 +351,7 @@ def find_prokura(c, ICO, elem2, conn, primary_sql_key, element):
vymaz_datum = str(get_prop(elem, "vymazDatum"))
text_prokurista = str(get_prop(elem, "hodnotaUdaje/textZaOsobu/value"))
prokurista_fo_id = find_fyzicka_osoba(c, ICO, elem, conn, primary_sql_key, element)
- adresa_id = sidlo3(c, elem, primary_sql_key)
+ adresa_id = find_sidlo(c, elem, primary_sql_key)
c.execute("INSERT INTO prokuriste (company_id, zapis_datum, vymaz_datum, prokurista_fo_id, adresa_id, text_prokurista) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, prokurista_fo_id, adresa_id, text_prokurista,))
else:
zapis_datum = str(get_prop(elem, "zapisDatum"))
@@ -353,11 +373,11 @@ def find_sole_shareholder(c, ICO, elem2, conn, primary_sql_key, element):
spol_ico = str(get_prop(elem, "osoba/ico"))
regCislo = str(get_prop(elem, "osoba/regCislo"))
akcionar_po_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo)
- adresa_id = sidlo3(c, elem, primary_sql_key)
+ adresa_id = find_sidlo(c, elem, primary_sql_key)
c.execute("INSERT into jediny_akcionar (company_id, zapis_datum, vymaz_datum, text_akcionar, akcionar_po_id, adresa_id) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, text_akcionar, akcionar_po_id, adresa_id,))
elif typ_akcionar == "F":
akcionar_fo_id = find_fyzicka_osoba(c, ICO, elem, conn, primary_sql_key, element)
- adresa_id = sidlo3(c, elem, primary_sql_key)
+ adresa_id = find_sidlo(c, elem, primary_sql_key)
c.execute("INSERT into jediny_akcionar (company_id, zapis_datum, vymaz_datum, text_akcionar, akcionar_fo_id, adresa_id) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, text_akcionar, akcionar_fo_id, adresa_id,))
except Exception as f:
print(f)
@@ -396,7 +416,7 @@ def find_konkurz(c, ICO, konkurz_elem, conn, primary_sql_key):
except:
pass
-def sidlo3(c, elem, primary_sql_key):
+def find_sidlo(c, elem, primary_sql_key):
try:
statNazev = get_prop(elem, ".//statNazev")
obec = get_prop(elem, ".//obec")
@@ -479,8 +499,14 @@ def find_clen_statut_org(c, ICO, elem, conn, relationship_table_key, element):
clenstviDo = str(get_prop(elem, "clenstviDo"))
if typ_osoby == "AngazmaFyzicke":
osoba_id = find_fyzicka_osoba(c, ICO, elem, conn, relationship_table_key, element)
- adresa_id = sidlo3(c, elem, relationship_table_key)
+ adresa_id = find_sidlo(c, elem, relationship_table_key)
c.execute("INSERT into statutarni_organ_clen_relation (statutarni_organ_id, osoba_id, adresa_id, zapis_datum, vymaz_datum, funkce_od, funkce_do, clenstvi_od, clenstvi_do, funkce) VALUES (?,?,?,?,?,?,?,?,?,?)", (relationship_table_key, osoba_id, adresa_id, zapis_datum, vymaz_datum, funkceOd, funkceDo, clenstviOd, clenstviDo, funkce_statutar_organu,))
+ if typ_osoby == "AngazmaPravnicke":
+ spol_ico = str(get_prop(elem, "osoba/ico"))
+ regCislo = str(get_prop(elem, "osoba/regCislo"))
+ prav_osoba_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo)
+ adresa_id = find_sidlo(c, elem, relationship_table_key)
+ c.execute("INSERT into statutarni_organ_clen_relation (statutarni_organ_id, prav_osoba_id, adresa_id, zapis_datum, vymaz_datum, funkce_od, funkce_do, clenstvi_od, clenstvi_do, funkce) VALUES (?,?,?,?,?,?,?,?,?,?)", (relationship_table_key, prav_osoba_id, adresa_id, zapis_datum, vymaz_datum, funkceOd, funkceDo, clenstviOd, clenstviDo, funkce_statutar_organu,))
except Exception as f:
print(f)
@@ -546,8 +572,14 @@ def find_clen_dr(c, ICO, elem, conn, relationship_table_key, element):
if typ_osoby == "AngazmaFyzicke":
osoba_id = find_fyzicka_osoba(c, ICO, elem, conn, relationship_table_key, element)
# adresa_id = find_and_store_address(c, elem)
- adresa_id = sidlo3(c, elem, relationship_table_key)
+ adresa_id = find_sidlo(c, elem, relationship_table_key)
c.execute("INSERT into dr_organ_clen_relation (dozorci_rada_id, osoba_id, adresa_id, zapis_datum, vymaz_datum, funkce_od, funkce_do, clenstvi_od, clenstvi_do, funkce) VALUES (?,?,?,?,?,?,?,?,?,?)", (relationship_table_key, osoba_id, adresa_id, zapis_datum, vymaz_datum, funkceOd, funkceDo, clenstviOd, clenstviDo, funkce_statutar_organu,))
+ elif typ_osoby == "AngazmaPravnicke":
+ spol_ico = str(get_prop(elem, "osoba/ico"))
+ regCislo = str(get_prop(elem, "osoba/regCislo"))
+ pravnicka_osoba_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo)
+ adresa_id = find_sidlo(c, elem, relationship_table_key)
+ c.execute("INSERT into dr_organ_clen_relation (dozorci_rada_id, pravnicka_osoba_id, adresa_id, zapis_datum, vymaz_datum, funkce_od, funkce_do, clenstvi_od, clenstvi_do, funkce) VALUES (?,?,?,?,?,?,?,?,?,?)", (relationship_table_key, pravnicka_osoba_id, adresa_id, zapis_datum, vymaz_datum, funkceOd, funkceDo, clenstviOd, clenstviDo, funkce_statutar_organu,))
except Exception as f:
print(f)