diff options
author | Petr Šmerkl <46304018+SveterCZE@users.noreply.github.com> | 2021-04-04 13:48:56 +0200 |
---|---|---|
committer | Petr Šmerkl <46304018+SveterCZE@users.noreply.github.com> | 2021-04-04 13:48:56 +0200 |
commit | ecc371c16005650d6d623125f407d44b362b7054 (patch) | |
tree | c0e0d1dfb229dbb4157a63bd32d4d4a3c73e0647 | |
parent | c93273a823c0af74f570c00015f5ee57bd6b9b68 (diff) | |
download | justice-ecc371c16005650d6d623125f407d44b362b7054.tar.gz |
some more clean-up changes
-rw-r--r-- | db_creation.py | 484 | ||||
-rw-r--r-- | justice_main.py | 2 | ||||
-rw-r--r-- | main.py | 2 | ||||
-rw-r--r-- | models.py | 202 | ||||
-rw-r--r-- | templates/extract-actual.html | 8 | ||||
-rw-r--r-- | templates/extract.html | 8 | ||||
-rw-r--r-- | update_db.py | 373 |
7 files changed, 280 insertions, 799 deletions
diff --git a/db_creation.py b/db_creation.py index b455119..a704a85 100644 --- a/db_creation.py +++ b/db_creation.py @@ -33,19 +33,12 @@ def create_tables(conn): "ico" TEXT NOT NULL UNIQUE, "nazev" TEXT, "zapis" DATE, - "sidlo" TEXT, "oddil" TEXT, "vlozka" TEXT, "soud" TEXT, PRIMARY KEY("id" AUTOINCREMENT) ); """ - adresy = """ CREATE TABLE "adresy" ( - "id" INTEGER NOT NULL, - "adresa_text" TEXT NOT NULL UNIQUE, - PRIMARY KEY("id" AUTOINCREMENT) - ); """ - adresy_v2 = """ CREATE TABLE "adresy_v2" ( "id" INTEGER NOT NULL UNIQUE, "stat" TEXT, @@ -169,25 +162,6 @@ def create_tables(conn): PRIMARY KEY("id" AUTOINCREMENT) ); """ - obce = """ CREATE TABLE "obce" ( - "id" INTEGER NOT NULL, - "obec_jmeno" TEXT NOT NULL UNIQUE, - PRIMARY KEY("id" AUTOINCREMENT) -); """ - - obce_relation = """ CREATE TABLE "obce_relation" ( - "company_id" INTEGER NOT NULL UNIQUE, - "obec_id" INTEGER NOT NULL, - FOREIGN KEY("obec_id") REFERENCES "obce"("id"), - FOREIGN KEY("company_id") REFERENCES "companies"("id") -); """ - - osoby = """ CREATE TABLE "osoby" ( - "id" INTEGER NOT NULL, - "osoba_jmeno" TEXT UNIQUE, - PRIMARY KEY("id" AUTOINCREMENT) -); """ - ostatni_skutecnosti = """ CREATE TABLE "ostatni_skutecnosti" ( "id" INTEGER NOT NULL UNIQUE, "company_id" INTEGER NOT NULL, @@ -319,16 +293,6 @@ def create_tables(conn): PRIMARY KEY("id" AUTOINCREMENT) ); """ - sidla = """ CREATE TABLE "sidla" ( - "id" INTEGER NOT NULL UNIQUE, - "company_id" INTEGER NOT NULL, - "zapis_datum" DATE NOT NULL, - "vymaz_datum" DATE, - "sidlo_adresa" TEXT, - PRIMARY KEY("id" AUTOINCREMENT), - FOREIGN KEY("company_id") REFERENCES "companies"("id") -); """ - sidlo_relation = """ CREATE TABLE "sidlo_relation" ( "id" INTEGER NOT NULL UNIQUE, "company_id" INTEGER NOT NULL, @@ -390,19 +354,6 @@ def create_tables(conn): PRIMARY KEY("id" AUTOINCREMENT) ); """ - ulice = """ CREATE TABLE "ulice" ( - "id" INTEGER NOT NULL, - "ulice_jmeno" TEXT NOT NULL UNIQUE, - PRIMARY KEY("id" AUTOINCREMENT) -); """ - - ulice_relation = """ CREATE TABLE "ulice_relation" ( - "company_id" INTEGER NOT NULL UNIQUE, - "ulice_id" INTEGER NOT NULL, - FOREIGN KEY("company_id") REFERENCES "companies"("id"), - FOREIGN KEY("ulice_id") REFERENCES "ulice"("id") -); """ - zakladni_kapital = """ CREATE TABLE "zakladni_kapital" ( "id" INTEGER NOT NULL UNIQUE, "company_id" INTEGER NOT NULL, @@ -445,11 +396,11 @@ def create_tables(conn): FOREIGN KEY("statutarni_organ_id") REFERENCES "statutarni_organ_relation"("id") ); """ - list_of_tables = [companies, adresy, adresy_v2, akcie, dr_relation, dr_organ_clen_relation, druhy_podilu, fyzicke_osoby, insolvency_events, - jediny_akcionar, konkurz_events, nazvy, obce, obce_relation, osoby, ostatni_skutecnosti, pocty_clenu_DR, pocty_clenu_organu, podily, pravni_formy, + list_of_tables = [companies, adresy_v2, akcie, dr_relation, dr_organ_clen_relation, druhy_podilu, fyzicke_osoby, insolvency_events, + jediny_akcionar, konkurz_events, nazvy, ostatni_skutecnosti, pocty_clenu_DR, pocty_clenu_organu, podily, pravni_formy, pravni_formy_relation, pravnicke_osoby, predmety_cinnosti, predmety_cinnosti_relation, prdmety_podnikani, predmety_podnikani_relation, - prokura_common_texts, prokuriste, sidla, sidlo_relation, spolecnici, statutarni_organ_clen_relation, statutarni_organ_relation, statutarni_organy, ulice, - ulice_relation, zakladni_kapital, zapis_soudy, zpusoby_jednani, zpusoby_jednani_relation] + prokura_common_texts, prokuriste, sidlo_relation, spolecnici, statutarni_organ_clen_relation, statutarni_organ_relation, statutarni_organy, + zakladni_kapital, zapis_soudy, zpusoby_jednani, zpusoby_jednani_relation] for elem in list_of_tables: try: c = conn.cursor() @@ -458,99 +409,71 @@ def create_tables(conn): print(e) def create_indices(conn): - companies = """ CREATE INDEX "companies index" ON "companies" ( - "id", - "ico", - "nazev", - "zapis", - "sidlo", - "oddil", - "vlozka", - "soud" + companies1 = """ CREATE INDEX "index companies1" ON "companies" ( + "id" +); """ + + companies2 = """ CREATE INDEX "index companies2" ON "companies" ( + "ico" ); """ - adresy = """ CREATE INDEX "index adresy" ON "adresy" ( - "adresa_text", + companies3 = """ CREATE INDEX "index companies3" ON "companies" ( + "nazev" +); """ + + companies4 = """ CREATE INDEX "index companies4" ON "companies" ( + "oddil" +); """ + + companies5 = """ CREATE INDEX "index companies5" ON "companies" ( + "vlozka" +); """ + + adresy1 = """ CREATE INDEX "index adresy1" ON "adresy_v2" ( "id" ); """ - adresa_text = """ CREATE INDEX "index adresy_adresa_text" ON "adresy" ( - "adresa_text" + adresy2 = """ CREATE INDEX "index adresy2" ON "adresy_v2" ( + "obec" ); """ - akcie = """ CREATE INDEX "index akcie" ON "akcie" ( - "id", - "company_id", - "zapis_datum", - "vymaz_datum", - "akcie_podoba", - "akcie_typ", - "akcie_pocet", - "akcie_hodnota_typ", - "akcie_hodnota_value", - "akcie_text" -); """ - - akcie2 = """ CREATE INDEX "index akcie 2" ON "akcie" ( + adresy3 = """ CREATE INDEX "index adresy3" ON "adresy_v2" ( + "ulice" +); """ + + akcie = """ CREATE INDEX "index akcie1" ON "akcie" ( + "id" +); """ + + akcie2 = """ CREATE INDEX "index akcie2" ON "akcie" ( "company_id" ); """ - akcionari = """ CREATE INDEX "index akcionari" ON "jediny_akcionar" ( - "id", - "company_id", - "zapis_datum", - "vymaz_datum", - "text_akcionar", - "akcionar_po_id", - "akcionar_fo_id", - "adresa_id" + akcionari1 = """ CREATE INDEX "index akcionari1" ON "jediny_akcionar" ( + "id" ); """ - companies_ico = """ CREATE INDEX "index companies_ico" ON "companies" ( - "ico" + akcionari2 = """ CREATE INDEX "index akcionari2" ON "jediny_akcionar" ( + "company_id" ); """ - companies_nazvy = """ CREATE INDEX "index companies_nazvy" ON "companies" ( - "nazev" + dr_clen_relation1 = """ CREATE INDEX "index dr clen relation1" ON "dr_organ_clen_relation" ( + "dozorci_rada_id" ); """ - companies_vznik = """ CREATE INDEX "index companies_vznik" ON "companies" ( - "zapis" + dr_clen_relation2 = """ CREATE INDEX "index dr clen relation2" ON "dr_organ_clen_relation" ( + "id" ); """ - dr_clen_relation = """ CREATE INDEX "index dr clen relation" ON "dr_organ_clen_relation" ( - "dozorci_rada_id", - "id", - "osoba_id", - "adresa_id", - "zapis_datum", - "vymaz_datum", - "funkce_od", - "funkce_do", - "clenstvi_od", - "clenstvi_do", - "funkce" -); """ - - dr_relation = """ CREATE INDEX "index dr relation" ON "dozorci_rada_relation" ( - "id", - "company_id", - "zapis_datum", - "vymaz_datum" + dr_relation = """ CREATE INDEX "index dr relation1" ON "dozorci_rada_relation" ( + "id" ); """ - dr_relation2 = """ CREATE INDEX "index dr relation v2" ON "dozorci_rada_relation" ( - "company_id", - "id", - "zapis_datum", - "vymaz_datum" + dr_relation2 = """ CREATE INDEX "index dr relation2" ON "dozorci_rada_relation" ( + "company_id" ); """ - insolvency_events = """ CREATE INDEX "index insolvency events" ON "insolvency_events" ( - "company_id", - "vymaz_datum", - "insolvency_event", - "zapis_datum", + insolvency1 = """ CREATE INDEX "index insolvency1" ON "insolvency_events" ( "id" ); """ @@ -558,262 +481,235 @@ def create_indices(conn): "company_id" ); """ - jmena_firem = """ CREATE INDEX "index jmena firem" ON "companies" ( - "nazev" + konkurz1 = """CREATE INDEX "index konkurz1" ON "konkurz_events" ( + "company_id" +); """ + + konkurz2 = """CREATE INDEX "index konkurz2" ON "konkurz_events" ( + "id" ); """ - nazvy_nazev_text = """ CREATE INDEX "index nazvy_nazev_text" ON "nazvy" ( + nazvy1 = """ CREATE INDEX "index nazvy1" ON "nazvy" ( "nazev_text" ); """ - nazvy2 = """ CREATE INDEX "index nazvy 2" ON "nazvy" ( + nazvy2 = """ CREATE INDEX "index nazvy2" ON "nazvy" ( "company_id" ); """ - obce = """ CREATE INDEX "index obce" ON "obce" ( - "id", - "obec_jmeno" + nazvy3 = """ CREATE INDEX "index nazvy3" ON "nazvy" ( + "id" ); """ - obec_jmeno = """ CREATE INDEX "index obec_jmeno" ON "obce" ( - "obec_jmeno" + ostatni_skutecnosti = """ CREATE INDEX "index ostatni skutecnosti1" ON "ostatni_skutecnosti" ( + "company_id" ); """ - osoby = """ CREATE INDEX "index osoby" ON "osoby" ( - "id", - "osoba_jmeno" + ostatni_skutecnosti2 = """ CREATE INDEX "index ostatni skutecnosti2" ON "ostatni_skutecnosti" ( + "id" ); """ - ostatni_skutecnosti2 = """ CREATE INDEX "index ostatni skutecnosti v2" ON "ostatni_skutecnosti" ( - "company_id", - "id", - "zapis_datum", - "vymaz_datum", - "ostatni_skutecnost" + pocty_clenu_organ1 = """ CREATE INDEX "index pocty clenu org1" ON "pocty_clenu_organu" ( + "organ_id" ); """ - pocty_clenu_organ = """ CREATE INDEX "index pocty clenu org_v2" ON "pocty_clenu_organu" ( - "organ_id", - "id", - "pocet_clenu_value", - "zapis_datum", - "vymaz_datum" + pocty_clenu_organ2 = """ CREATE INDEX "index pocty clenu org2" ON "pocty_clenu_organu" ( + "id" ); """ - podily = """ CREATE INDEX "index podily" ON "podily" ( - "id", - "spolecnik_id", - "zapis_datum", - "vymaz_datum", - "druh_podilu_id", - "vklad_typ", - "vklad_text", - "souhrn_typ", - "souhrn_text", - "splaceni_typ", - "splaceni_text" -); """ - - podily_spolecnik = """ CREATE INDEX "index podily spolecnik_id" ON "podily" ( - "spolecnik_id", - "id", - "zapis_datum", - "vymaz_datum", - "druh_podilu_id", - "vklad_typ", - "vklad_text", - "souhrn_typ", - "souhrn_text", - "splaceni_typ", - "splaceni_text" + podily1 = """ CREATE INDEX "index podily1" ON "podily" ( + "id" +); """ + + podily2 = """ CREATE INDEX "index podily2" ON "podily" ( + "spolecnik_id" ); """ pravni_formy = """ CREATE INDEX "index pravni_formy" ON "pravni_formy" ( "pravni_forma" ); """ - pravni_formy_relation_2 = """ CREATE INDEX "index pravni_formy_relation_2" ON "pravni_formy_relation" ( + pravni_formy_relation1 = """ CREATE INDEX "index pravni_formy_relation1" ON "pravni_formy_relation" ( "company_id" ); """ - predmety_cinnosti_relation_v2 = """ CREATE INDEX "index predmety cinnosti relation v2" ON "predmety_cinnosti_relation" ( - "company_id", - "id", - "predmet_cinnosti_id", - "zapis_datum", - "vymaz_datum" + pravni_formy_relation2 = """ CREATE INDEX "index pravni_formy_relation2" ON "pravni_formy_relation" ( + "id" ); """ - predmety_podnikani_relation = """ CREATE INDEX "index predmety podnikani relation v2" ON "predmety_podnikani_relation" ( - "company_id", - "id", - "predmet_podnikani_id", - "zapis_datum", - "vymaz_datum" + predmety_cinnosti_relation1 = """ CREATE INDEX "index predmety cinnosti relation1" ON "predmety_cinnosti_relation" ( + "company_id" +); """ + + predmety_cinnosti_relation2 = """ CREATE INDEX "index predmety cinnosti relation2" ON "predmety_cinnosti_relation" ( + "id" +); """ + + predmety_cinnosti_relation3 = """ CREATE INDEX "index predmety cinnosti relation3" ON "predmety_cinnosti_relation" ( + "predmet_cinnosti_id" ); """ - predmety_cinnosti = """ CREATE INDEX "index predmety_cinnosti" ON "predmety_cinnosti" ( + predmety_podnikani_relation1 = """ CREATE INDEX "index predmety podnikani relation1" ON "predmety_podnikani_relation" ( + "company_id" +); """ + + predmety_podnikani_relation2 = """ CREATE INDEX "index predmety podnikani relation2" ON "predmety_podnikani_relation" ( + "id" +); """ + + predmety_podnikani_relation3 = """ CREATE INDEX "index predmety podnikani relation3" ON "predmety_podnikani_relation" ( + "prdemet_podnikani_id" +); """ + + predmety_cinnosti1 = """ CREATE INDEX "index predmety_cinnosti1" ON "predmety_cinnosti" ( "predmet_cinnosti" ); """ - predmety_podnikani = """ CREATE INDEX "index predmety_podnikani" ON "predmety_podnikani" ( + predmety_cinnosti2 = """ CREATE INDEX "index predmety_cinnosti2" ON "predmety_cinnosti" ( + "id" +); """ + + predmety_podnikani1 = """ CREATE INDEX "index predmety_podnikani1" ON "predmety_podnikani" ( "predmet_podnikani" ); """ - prokuriste = """ CREATE INDEX "index prokuriste" ON "prokuriste" ( - "id", - "company_id", - "zapis_datum", - "vymaz_datum", - "prokurista_fo_id", - "adresa_id", - "text_prokurista" -); """ - - sidlo = """ CREATE INDEX "index sidlo" ON "sidla" ( - "company_id", - "vymaz_datum", - "sidlo_adresa", - "id", - "zapis_datum" + predmety_podnikani2 = """ CREATE INDEX "index predmety_podnikani2" ON "predmety_podnikani" ( + "id" ); """ - sidlo_relation = """ CREATE INDEX "index sidlo relation" ON "sidlo_relation" ( - "id", - "company_id", - "sidlo_id", - "zapis_datum", - "vymaz_datum" + prokuriste1 = """ CREATE INDEX "index prokuriste1" ON "prokuriste" ( + "id" ); """ - sidlo_relation_2 = """ CREATE INDEX "index sidlo relation 2" ON "sidlo_relation" ( + prokuriste2 = """ CREATE INDEX "index prokuriste2" ON "prokuriste" ( "company_id" ); """ - sidlo2 = """ CREATE INDEX "index sidlo2" ON "sidla" ( + prokuriste3 = """ CREATE INDEX "index prokuriste3" ON "prokuriste" ( + "prokurista_fo_id" +); """ + + prokuriste4 = """ CREATE INDEX "index prokuriste4" ON "prokuriste" ( + "adresa_id" +); """ + + sidlo_relation1 = """ CREATE INDEX "index sidlo relation1" ON "sidlo_relation" ( + "id" +); """ + + sidlo_relation_2 = """ CREATE INDEX "index sidlo relation2" ON "sidlo_relation" ( + "company_id" +); """ + + sidlo_relation_3 = """ CREATE INDEX "index sidlo relation3" ON "sidlo_relation" ( + "sidlo_id" +); """ + + soudni_zapis1 = """ CREATE INDEX "index soudni_zapis1" ON "zapis_soudy" ( "company_id" ); """ - soudni_zapis = """ CREATE INDEX "index soudni_zapis" ON "zapis_soudy" ( - "company_id", - "vymaz_datum", - "oddil", - "vlozka", - "soud", - "zapis_datum", + soudni_zapis2 = """ CREATE INDEX "index soudni_zapis2" ON "zapis_soudy" ( "id" ); """ - spolecnici = """ CREATE INDEX "index spolecnici" ON "spolecnici" ( - "id", - "company_id", - "spolecnik_fo_id", - "spolecnik_po_id", - "zapis_datum", - "vymaz_datum", - "adresa_id", - "text_spolecnik" + spolecnici1 = """ CREATE INDEX "index spolecnici1" ON "spolecnici" ( + "id" ); """ - spolecnici2 = """ CREATE INDEX "index spolecnici 2" ON "spolecnici" ( - "company_id", - "id", - "spolecnik_fo_id", - "spolecnik_po_id", - "zapis_datum", - "vymaz_datum", - "adresa_id", - "text_spolecnik" + spolecnici2 = """ CREATE INDEX "index spolecnici2" ON "spolecnici" ( + "company_id" ); """ - statutarni_organy = """ CREATE INDEX "index statutarn_organy" ON "statutarni_organy" ( - "id", - "statutarni_organ_text" + spolecnici3 = """ CREATE INDEX "index spolecnici3" ON "spolecnici" ( + "spolecnik_fo_id" ); """ - statutarni_organy_relation = """ CREATE INDEX "index statutarni organ relation" ON "statutarni_organ_relation" ( - "id", - "company_id", - "statutarni_organ_id", - "zapis_datum", - "vymaz_datum" + spolecnici4 = """ CREATE INDEX "index spolecnici4" ON "spolecnici" ( + "spolecnik_po_id" ); """ - statutarni_organy_relation_v2 = """ CREATE INDEX "index statutarni organ relation v2" ON "statutarni_organ_clen_relation" ( - "statutarni_organ_id", + spolecnici5 = """ CREATE INDEX "index spolecnici5" ON "spolecnici" ( + "adresa_id" +); """ + + statutarni_organy = """ CREATE INDEX "index statutarn_organy" ON "statutarni_organy" ( "id", - "osoba_id", - "adresa_id", - "zapis_datum", - "vymaz_datum", - "funkce_od", - "funkce_do", - "clenstvi_od", - "clenstvi_do", - "funkce" -); """ - - statutarni_organy_relation_3 = """ CREATE INDEX "index statutarni organ relation 3" ON "statutarni_organ_relation" ( - "company_id" + "statutarni_organ_text" ); """ - v2 = """ CREATE INDEX "index v2" ON "statutarni_organ_relation" ( - "statutarni_organ_id", - "company_id", + statutarni_organy_relation1 = """ CREATE INDEX "index statutarni organ relation1" ON "statutarni_organ_relation" ( "id" ); """ - zakladni_kapital = """ CREATE INDEX "index zakladni kapital" ON "zakladni_kapital" ( - "company_id" + statutarni_organy_relation2 = """ CREATE INDEX "index statutarni organ relation2" ON "statutarni_organ_clen_relation" ( + "statutarni_organ_id" ); """ - - zapis2 = """ CREATE INDEX "index zapis2" ON "zapis_soudy" ( + + statutarni_organy_relation_3 = """ CREATE INDEX "index statutarni organ relation 3" ON "statutarni_organ_relation" ( "company_id" ); """ - zapis_soudy = """ CREATE INDEX "index zapis_soudy" ON "zapis_soudy" ( - "id", - "company_id", - "zapis_datum", - "vymaz_datum", - "oddil", - "vlozka", - "soud" + zakladni_kapital1 = """ CREATE INDEX "index zakladni kapital1" ON "zakladni_kapital" ( + "company_id" ); """ + zakladni_kapital2 = """ CREATE INDEX "index zakladni kapital2" ON "zakladni_kapital" ( + "id" +); """ + zpusob_jednani = """ CREATE INDEX "index zpusob_jednani" ON "zpusoby_jednani" ( - "id", - "zpusob_jednani_text" + "id" ); """ - zpusob_jednani_relation = """ CREATE INDEX "index zpusob_jednani_relation" ON "zpusoby_jednani_relation" ( - "id", - "statutarni_organ_id", - "zpusob_jednani_id", - "zapis_datum", - "vymaz_datum" + zpusob_jednani_relation1 = """ CREATE INDEX "index zpusob_jednani_relation" ON "zpusoby_jednani_relation" ( + "id" ); """ - zpusob_jednani_relation_2 = """ CREATE INDEX "index zpusob jednani relation 2" ON "zpusoby_jednani_relation" ( + zpusob_jednani_relation2 = """ CREATE INDEX "index zpusob jednani relation2" ON "zpusoby_jednani_relation" ( "statutarni_organ_id" ); """ - zpusoby_jednani = """ CREATE INDEX "index zpusoby_jednani" ON "zpusoby_jednani" ( - "zpusob_jednani_text" + zpusob_jednani_relation3 = """ CREATE INDEX "index zpusob jednani relation3" ON "zpusoby_jednani_relation" ( + "zpusob_jednani_id" ); """ - pravnicke_osoby_index = """ CREATE INDEX "pravnicke_osoby_index" ON "pravnicke_osoby" ( - "ico", - "reg_cislo", + pravnicke_osoby1 = """ CREATE INDEX "pravnicke_osoby1" ON "pravnicke_osoby" ( + "ico" +); """ + + pravnicke_osoby2 = """ CREATE INDEX "pravnicke_osoby2" ON "pravnicke_osoby" ( + "id" +); """ + + pravnicke_osoby3 = """ CREATE INDEX "pravnicke_osoby3" ON "pravnicke_osoby" ( + "reg_cislo" +); """ + + pravnicke_osoby4 = """ CREATE INDEX "pravnicke_osoby4" ON "pravnicke_osoby" ( "nazev" ); """ - list_of_indices = [companies, adresy, adresa_text, akcie, akcie2, akcionari, companies_ico, companies_nazvy, companies_vznik, dr_clen_relation, dr_relation, dr_relation2, insolvency_events, insolvency2, jmena_firem, nazvy_nazev_text, nazvy2, obce, obec_jmeno, osoby, ostatni_skutecnosti2, - pocty_clenu_organ, podily, podily_spolecnik, pravni_formy, pravni_formy_relation_2, predmety_cinnosti_relation_v2, predmety_podnikani_relation, predmety_cinnosti, predmety_podnikani, prokuriste, sidlo, sidlo_relation, sidlo_relation_2, sidlo2, soudni_zapis, spolecnici, spolecnici2, statutarni_organy, statutarni_organy_relation, - statutarni_organy_relation_v2, statutarni_organy_relation_3, v2, zakladni_kapital, zapis2, zapis_soudy, zpusob_jednani, zpusob_jednani_relation, zpusob_jednani_relation_2, zpusoby_jednani, pravnicke_osoby_index] + fyzicke_osoby1 = """ CREATE INDEX "fyzicke_osoby1" ON "fyzicke_osoby" ( + "id" +); """ + + list_of_indices = [companies1, companies2, companies3, companies4, companies5, adresy1, adresy2, adresy3, + akcie, akcie2, akcionari1, akcionari2, dr_clen_relation1, dr_clen_relation2, dr_relation, dr_relation2, + insolvency1, insolvency2, konkurz1, konkurz2, nazvy1, nazvy2, nazvy3, ostatni_skutecnosti, ostatni_skutecnosti2, + pocty_clenu_organ1, pocty_clenu_organ2, podily1, podily2, pravni_formy, pravni_formy_relation1, pravni_formy_relation2, + predmety_cinnosti_relation1, predmety_cinnosti_relation2, predmety_cinnosti_relation3, predmety_podnikani_relation1, predmety_podnikani_relation2, + predmety_podnikani_relation3, predmety_cinnosti1, predmety_cinnosti2, predmety_podnikani1, predmety_podnikani2, prokuriste1, + prokuriste2, prokuriste3, prokuriste4, sidlo_relation1, sidlo_relation_2, sidlo_relation_3, soudni_zapis1, soudni_zapis2, spolecnici1, + spolecnici2, spolecnici3, spolecnici4, spolecnici5, statutarni_organy, statutarni_organy_relation1, statutarni_organy_relation2, + statutarni_organy_relation_3, zakladni_kapital1, zakladni_kapital2, zpusob_jednani, zpusob_jednani_relation1, zpusob_jednani_relation2, + zpusob_jednani_relation3, pravnicke_osoby1, pravnicke_osoby2, pravnicke_osoby3, pravnicke_osoby4, fyzicke_osoby1] + i = 0 for elem in list_of_indices: + i += 1 try: c = conn.cursor() c.execute(elem) except Exception as e: + print(i) print(e)
\ No newline at end of file diff --git a/justice_main.py b/justice_main.py index 4dca06d..348ee59 100644 --- a/justice_main.py +++ b/justice_main.py @@ -8,7 +8,7 @@ def main(): soudy = ["praha", "plzen", "brno", "ceske_budejovice", "hradec_kralove", "ostrava", "usti_nad_labem"]
DB_name = "justice.db"
create_DB(DB_name)
- # download_data(typy_po, soudy)
+ download_data(typy_po, soudy)
update_DB(typy_po, soudy, DB_name)
main()
\ No newline at end of file @@ -4,7 +4,7 @@ from db_setup import init_db, db_session from forms import JusticeSearchForm, CompanyForm from flask import flash, render_template, request, redirect # from models import Company, Soud -from models import Company, Obce, Ulice, Insolvency_Events, Konkurz_Events, Predmet_Podnikani, Predmety_Podnikani_Association, Predmet_Cinnosti, Predmety_Cinnosti_Association +from models import Company, Insolvency_Events, Konkurz_Events, Predmet_Podnikani, Predmety_Podnikani_Association, Predmet_Cinnosti, Predmety_Cinnosti_Association from models import Zakladni_Kapital, Akcie, Nazvy, Sidlo, Sidlo_Association, Pravni_Forma_Association_v2, Pravni_Formy, Statutarni_Organ_Association, Statutarni_Organy, Pocty_Clenu_Organu from models import Zpusob_Jednani_Association, Zpusob_Jednani, Statutarni_Organ_Clen_Association, Fyzicka_Osoba, Spolecnici_Association, Podily_Association, Druhy_Podilu, Pravnicka_Osoba from models import Prokurista_Association, Jediny_Akcionar_Association, Prokura_Common_Text_Association, Soudni_Zapisy @@ -1,10 +1,5 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" -Created on Sun Jan 17 09:56:14 2021 - -@author: sveter -""" from app import db from sqlalchemy.orm import relationship, backref @@ -78,11 +73,7 @@ class MyType(types.TypeDecorator): impl = types.Unicode - # def process_bind_param(self, value, dialect): - # return convert_date_to_string(value) - def process_result_value(self, value, dialect): - # return "PREFIX:" + value return convert_date_to_string(value) def copy(self, **kw): @@ -92,34 +83,28 @@ class MySoud(types.TypeDecorator): impl = types.Unicode - # def process_bind_param(self, value, dialect): - # return convert_soud_to_string(value) - def process_result_value(self, value, dialect): - # return "PREFIX:" + value return convert_soud_to_string(value) def copy(self, **kw): return MySoud(self.impl.length) -association_table = db.Table("obce_relation", - db.Column("company_id", db.Integer, db.ForeignKey("companies.id"), primary_key=True, nullable=False), - db.Column("obec_id", db.Integer, db.ForeignKey("obce.id"), nullable=False), - # db.PrimaryKeyConstraint('company_id', 'obec_id') - ) +# association_table = db.Table("obce_relation", +# db.Column("company_id", db.Integer, db.ForeignKey("companies.id"), primary_key=True, nullable=False), +# db.Column("obec_id", db.Integer, db.ForeignKey("obce.id"), nullable=False), +# ) -ulice_association = db.Table("ulice_relation", - db.Column("company_id", db.Integer, db.ForeignKey("companies.id"), primary_key=True, nullable=False), - db.Column("ulice_id", db.Integer, db.ForeignKey("ulice.id"), nullable=False), - # db.PrimaryKeyConstraint('company_id', 'obec_id') - ) +# ulice_association = db.Table("ulice_relation", +# db.Column("company_id", db.Integer, db.ForeignKey("companies.id"), primary_key=True, nullable=False), +# db.Column("ulice_id", db.Integer, db.ForeignKey("ulice.id"), nullable=False), +# ) class Predmety_Podnikani_Association(db.Model): __tablename__ = 'predmety_podnikani_relation' id = db.Column(db.Integer) - company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False) - predmet_podnikani_id = db.Column(db.Integer, db.ForeignKey('predmety_podnikani.id'), nullable=False, primary_key=True) + company_id = db.Column(db.Integer, db.ForeignKey('companies.id')) + predmet_podnikani_id = db.Column(db.Integer, db.ForeignKey('predmety_podnikani.id'), primary_key=True) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) predmet_podnikani = db.relationship("Predmet_Podnikani", back_populates="company_predmet_podnikani") @@ -128,76 +113,61 @@ class Predmety_Podnikani_Association(db.Model): class Predmety_Cinnosti_Association(db.Model): __tablename__ = 'predmety_cinnosti_relation' id = db.Column(db.Integer) - company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False) - predmet_cinnosti_id = db.Column(db.Integer, db.ForeignKey('predmety_cinnosti.id'), nullable=False, primary_key=True) + company_id = db.Column(db.Integer, db.ForeignKey('companies.id')) + predmet_cinnosti_id = db.Column(db.Integer, db.ForeignKey('predmety_cinnosti.id'), primary_key=True) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) - predmet_cinnosti = db.relationship("Predmet_Cinnosti", back_populates="company_predmet_cinnosti") - company = db.relationship("Company", back_populates="predmet_cinnosti") - -# class Sidlo_Association(db.Model): -# __tablename__ = 'sidlo_relation' -# id = db.Column(db.Integer, primary_key=True) -# company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False) -# sidlo_id = db.Column(db.Integer, db.ForeignKey('adresy.id'), nullable=False) -# zapis_datum = db.Column(MyType) -# vymaz_datum = db.Column(MyType) -# sidlo_text = db.relationship("Sidlo", back_populates="company_sidlo") -# company = db.relationship("Company", back_populates="sidlo_text") + predmet_cinnosti = db.relationship("Predmet_Cinnosti") + company = db.relationship("Company") class Sidlo_Association(db.Model): __tablename__ = 'sidlo_relation' id = db.Column(db.Integer, primary_key=True) - company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False) - sidlo_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id'), nullable=False) + company_id = db.Column(db.Integer, db.ForeignKey('companies.id')) + sidlo_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id')) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) - sidlo_text = db.relationship("Adresy_v2", back_populates="company_sidlo") - company = db.relationship("Company", back_populates="sidlo_text") + sidlo_text = db.relationship("Adresy_v2") + company = db.relationship("Company") class Pravni_Forma_Association_v2(db.Model): __tablename__ = 'pravni_formy_relation' id = db.Column(db.Integer, primary_key=True) - company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False) - pravni_forma_id = db.Column(db.Integer, db.ForeignKey('pravni_formy.id'), nullable=False) + company_id = db.Column(db.Integer, db.ForeignKey('companies.id')) + pravni_forma_id = db.Column(db.Integer, db.ForeignKey('pravni_formy.id')) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) - pravni_forma_text = db.relationship("Pravni_Formy", back_populates="company_pravni_forma") - company = db.relationship("Company", back_populates="pravni_forma_text") + pravni_forma_text = db.relationship("Pravni_Formy") + company = db.relationship("Company") class Statutarni_Organ_Association(db.Model): __tablename__ = 'statutarni_organ_relation' id = db.Column(db.Integer) - company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False) - statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organy.id'), nullable=False, primary_key=True) + company_id = db.Column(db.Integer, db.ForeignKey('companies.id')) + statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organy.id'), primary_key=True) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) - statutarni_organ_text = db.relationship("Statutarni_Organy", back_populates="company_statutarni_organ") - company = db.relationship("Company", back_populates="statutarni_organ_text") - pocet_clenu = db.relationship("Pocty_Clenu_Organu", backref="statutarni_organ_relation") - zpusoby_jednani = db.relationship("Zpusob_Jednani_Association", back_populates="statutarni_organ") + statutarni_organ_text = db.relationship("Statutarni_Organy") + company = db.relationship("Company") + pocet_clenu = db.relationship("Pocty_Clenu_Organu") + zpusoby_jednani = db.relationship("Zpusob_Jednani_Association") clenove = db.relationship("Statutarni_Organ_Clen_Association") class Dozorci_Rada_Association(db.Model): __tablename__ = 'dozorci_rada_relation' id = db.Column(db.Integer, primary_key=True) - company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False) - # statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organy.id'), nullable=False, primary_key=True) + company_id = db.Column(db.Integer, db.ForeignKey('companies.id')) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) - # statutarni_organ_text = db.relationship("Statutarni_Organy", back_populates="company_statutarni_organ") - # company = db.relationship("Company", back_populates="statutarni_organ_text") - pocet_clenu = db.relationship("Pocty_Clenu_DR", backref="dozorci_rada_relation") - # zpusoby_jednani = db.relationship("Zpusob_Jednani_Association", back_populates="statutarni_organ") + pocet_clenu = db.relationship("Pocty_Clenu_DR") clenove = db.relationship("Dozorci_Rada_Clen_Association") class Statutarni_Organ_Clen_Association(db.Model): __tablename__ = 'statutarni_organ_clen_relation' id = db.Column(db.Integer, primary_key=True) - statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organ_relation.id'), nullable=False) - osoba_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id'), nullable=False) - # adresa_id = db.Column(db.Integer, db.ForeignKey('adresy.id'), nullable=False) - adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id'), nullable=False) + statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organ_relation.id')) + osoba_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id')) + adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id')) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) funkce_od = db.Column(MyType) @@ -205,17 +175,15 @@ class Statutarni_Organ_Clen_Association(db.Model): clenstvi_od = db.Column(MyType) clenstvi_do = db.Column(MyType) funkce = db.Column(db.String) - # adresa = db.relationship("Sidlo") adresa = db.relationship("Adresy_v2") jmeno = db.relationship("Fyzicka_Osoba") class Dozorci_Rada_Clen_Association(db.Model): __tablename__ = 'dr_organ_clen_relation' id = db.Column(db.Integer, primary_key=True) - dozorci_rada_id = db.Column(db.Integer, db.ForeignKey('dozorci_rada_relation.id'), nullable=False) - osoba_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id'), nullable=False) - # adresa_id = db.Column(db.Integer, db.ForeignKey('adresy.id'), nullable=False) - adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id'), nullable=False) + dozorci_rada_id = db.Column(db.Integer, db.ForeignKey('dozorci_rada_relation.id')) + osoba_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id')) + adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id')) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) funkce_od = db.Column(MyType) @@ -223,22 +191,19 @@ class Dozorci_Rada_Clen_Association(db.Model): clenstvi_od = db.Column(MyType) clenstvi_do = db.Column(MyType) funkce = db.Column(db.String) - # adresa = db.relationship("Sidlo") adresa = db.relationship("Adresy_v2") jmeno = db.relationship("Fyzicka_Osoba") class Spolecnici_Association(db.Model): __tablename__ = "spolecnici" id = db.Column(db.Integer, primary_key=True) - company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False) - spolecnik_fo_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id'), nullable=False) - spolecnik_po_id = db.Column(db.Integer, db.ForeignKey('pravnicke_osoby.id'), nullable=False) + company_id = db.Column(db.Integer, db.ForeignKey('companies.id')) + spolecnik_fo_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id')) + spolecnik_po_id = db.Column(db.Integer, db.ForeignKey('pravnicke_osoby.id')) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) - # adresa_id = db.Column(db.Integer, db.ForeignKey('adresy.id'), nullable=False) - adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id'), nullable=False) + adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id')) text_spolecnik = db.Column(db.String) - # adresa = db.relationship("Sidlo") adresa = db.relationship("Adresy_v2") jmeno = db.relationship("Fyzicka_Osoba") oznaceni_po = db.relationship("Pravnicka_Osoba") @@ -251,9 +216,7 @@ class Prokurista_Association(db.Model): zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) prokurista_fo_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id')) - # adresa_id = db.Column(db.Integer, db.ForeignKey('adresy.id')) - adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id'), nullable=False) - # adresa = db.relationship("Sidlo") + adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id')) adresa = db.relationship("Adresy_v2") jmeno = db.relationship("Fyzicka_Osoba") text_prokurista = db.Column(db.String) @@ -275,9 +238,7 @@ class Jediny_Akcionar_Association(db.Model): text_akcionar = db.Column(db.String) akcionar_fo_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id')) akcionar_po_id = db.Column(db.Integer, db.ForeignKey('pravnicke_osoby.id')) - # adresa_id = db.Column(db.Integer, db.ForeignKey('adresy.id')) - # adresa = db.relationship("Sidlo") - adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id'), nullable=False) + adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id')) adresa = db.relationship("Adresy_v2") jmeno = db.relationship("Fyzicka_Osoba") oznaceni_po = db.relationship("Pravnicka_Osoba") @@ -285,10 +246,10 @@ class Jediny_Akcionar_Association(db.Model): class Podily_Association(db.Model): __tablename__ = "podily" id = db.Column(db.Integer, primary_key=True) - spolecnik_id = db.Column(db.Integer, db.ForeignKey('spolecnici.id'), nullable=False) + spolecnik_id = db.Column(db.Integer, db.ForeignKey('spolecnici.id')) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) - druh_podilu_id = db.Column(db.Integer, db.ForeignKey('druhy_podilu.id'), nullable=False) + druh_podilu_id = db.Column(db.Integer, db.ForeignKey('druhy_podilu.id')) vklad_typ = db.Column(db.String) vklad_text = db.Column(db.String) souhrn_typ = db.Column(db.String) @@ -300,12 +261,12 @@ class Podily_Association(db.Model): class Zpusob_Jednani_Association(db.Model): __tablename__ = 'zpusoby_jednani_relation' id = db.Column(db.Integer, primary_key=True) - statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organ_relation.id'), nullable=False) - zpusob_jednani_id = db.Column(db.Integer, db.ForeignKey('zpusoby_jednani.id'), nullable=False) + statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organ_relation.id')) + zpusob_jednani_id = db.Column(db.Integer, db.ForeignKey('zpusoby_jednani.id')) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) - zpusob_jednani = relationship("Zpusob_Jednani", back_populates="zpusob_jednani_rship") - statutarni_organ = relationship("Statutarni_Organ_Association", back_populates="zpusoby_jednani") + zpusob_jednani = relationship("Zpusob_Jednani") + statutarni_organ = relationship("Statutarni_Organ_Association") class Company(db.Model): __tablename__ = "companies" @@ -313,30 +274,26 @@ class Company(db.Model): ico = db.Column(db.String) nazev = db.Column(db.String) zapis = db.Column(MyType) - sidlo = db.Column(db.String) oddil = db.Column(db.String) vlozka = db.Column(db.String) soud = db.Column(MySoud) - obec = db.relationship("Obce", secondary=association_table, backref="companies") - ulice = db.relationship("Ulice", secondary=ulice_association, backref="companies") - insolvence = db.relationship("Insolvency_Events", backref="companies") - konkurz = db.relationship("Konkurz_Events", backref="companies") - predmet_podnikani = db.relationship("Predmety_Podnikani_Association", back_populates="company") - predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association", back_populates="company") - zakladni_kapital = db.relationship("Zakladni_Kapital", backref="companies") - ostatni_skutecnosti = db.relationship("Ostatni_Skutecnosti", backref="companies") - akcie = db.relationship("Akcie", backref="companies") - obchodni_firma = db.relationship("Nazvy", backref="companies") + insolvence = db.relationship("Insolvency_Events") + konkurz = db.relationship("Konkurz_Events") + predmet_podnikani = db.relationship("Predmety_Podnikani_Association") + predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association") + zakladni_kapital = db.relationship("Zakladni_Kapital") + ostatni_skutecnosti = db.relationship("Ostatni_Skutecnosti") + akcie = db.relationship("Akcie") + obchodni_firma = db.relationship("Nazvy") soudni_zapis = db.relationship("Soudni_Zapisy") - # sidlo_text = db.relationship("Sidlo_Association", back_populates="company") - pravni_forma_text = db.relationship("Pravni_Forma_Association_v2", back_populates="company") - statutarni_organ_text = db.relationship("Statutarni_Organ_Association", back_populates="company") + pravni_forma_text = db.relationship("Pravni_Forma_Association_v2") + statutarni_organ_text = db.relationship("Statutarni_Organ_Association") dozorci_rada_text = db.relationship("Dozorci_Rada_Association") spolecnici = db.relationship("Spolecnici_Association") prokurista = db.relationship("Prokurista_Association") prokura_common_text = db.relationship("Prokura_Common_Text_Association") jediny_akcionar = db.relationship("Jediny_Akcionar_Association") - sidlo_text = db.relationship("Sidlo_Association", back_populates="company") + sidlo_text = db.relationship("Sidlo_Association") class Adresy_v2(db.Model): __tablename__ = "adresy_v2" @@ -352,7 +309,7 @@ class Adresy_v2(db.Model): komplet_adresa = db.Column(db.String) cisloEv = db.Column(db.Integer) cisloText = db.Column(db.String) - company_sidlo = db.relationship("Sidlo_Association", back_populates="sidlo_text") + company_sidlo = db.relationship("Sidlo_Association") def __repr__(self): joined_address = "" @@ -376,7 +333,7 @@ class Adresy_v2(db.Model): joined_address += str(self.cisloEv) + ", " if (self.castObce != "0") and (self.castObce != self.obec): joined_address += self.castObce + ", " - if self.psc != "0": + if self.psc != "0" and self.psc != None: joined_address += self.psc + " " if self.obec != "0": joined_address += self.obec @@ -384,23 +341,17 @@ class Adresy_v2(db.Model): joined_address += ", " + self.stat return joined_address -class Obce(db.Model): - __tablename__ = "obce" - id = db.Column(db.Integer, primary_key=True) - obec_jmeno = db.Column(db.String) - company_obec = db.relationship("Company", secondary=association_table, backref="obce") - -class Ulice(db.Model): - __tablename__ = "ulice" - id = db.Column(db.Integer, primary_key=True) - ulice_jmeno = db.Column(db.String) - company_ulice = db.relationship("Company", secondary=ulice_association) +# class Obce(db.Model): +# __tablename__ = "obce" +# id = db.Column(db.Integer, primary_key=True) +# obec_jmeno = db.Column(db.String) +# company_obec = db.relationship("Company", secondary=association_table, backref="obce") -# class Pravni_Forma(db.Model): -# __tablename__ = "pravni_formy" +# class Ulice(db.Model): +# __tablename__ = "ulice" # id = db.Column(db.Integer, primary_key=True) -# pravni_forma = db.Column(db.String) -# company_pravni_forma = db.relationship("Company", secondary=pravni_forma_association) +# ulice_jmeno = db.Column(db.String) +# company_ulice = db.relationship("Company", secondary=ulice_association) class Insolvency_Events(db.Model): __tablename__ = "insolvency_events" @@ -408,7 +359,6 @@ class Insolvency_Events(db.Model): company_id = db.Column(db.String, db.ForeignKey("companies.id")) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) - # company = db.relationship("Company", backref="insolvency_events") insolvency_event = db.Column(db.String) class Konkurz_Events(db.Model): @@ -417,7 +367,6 @@ class Konkurz_Events(db.Model): company_id = db.Column(db.String, db.ForeignKey("companies.id")) zapis_datum = db.Column(MyType) vymaz_datum = db.Column(MyType) - # company = db.relationship("Company", backref="insolvency_events") konkurz_event = db.Column(db.String) class Zakladni_Kapital(db.Model): @@ -435,31 +384,30 @@ class Predmet_Podnikani(db.Model): __tablename__ = "predmety_podnikani" id = db.Column(db.Integer, primary_key=True) predmet_podnikani = db.Column(db.String) - company_predmet_podnikani = db.relationship("Predmety_Podnikani_Association", back_populates="predmet_podnikani") + company_predmet_podnikani = db.relationship("Predmety_Podnikani_Association") class Predmet_Cinnosti(db.Model): __tablename__ = "predmety_cinnosti" id = db.Column(db.Integer, primary_key=True) predmet_cinnosti = db.Column(db.String) - company_predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association", back_populates="predmet_cinnosti") + company_predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association") class Sidlo(db.Model): __tablename__ = "adresy" id = db.Column(db.Integer, primary_key=True) adresa_text = db.Column(db.String) - # company_sidlo = db.relationship("Sidlo_Association", back_populates="sidlo_text") class Pravni_Formy(db.Model): __tablename__ = "pravni_formy" id = db.Column(db.Integer, primary_key=True) pravni_forma = db.Column(db.String) - company_pravni_forma = db.relationship("Pravni_Forma_Association_v2", back_populates="pravni_forma_text") + company_pravni_forma = db.relationship("Pravni_Forma_Association_v2") class Statutarni_Organy(db.Model): __tablename__ = "statutarni_organy" id = db.Column(db.Integer, primary_key=True) statutarni_organ_text = db.Column(db.String) - company_statutarni_organ = db.relationship("Statutarni_Organ_Association", back_populates="statutarni_organ_text") + company_statutarni_organ = db.relationship("Statutarni_Organ_Association") class Ostatni_Skutecnosti(db.Model): __tablename__ = "ostatni_skutecnosti" @@ -520,7 +468,7 @@ class Zpusob_Jednani(db.Model): __tablename__ = "zpusoby_jednani" id = db.Column(db.Integer, primary_key=True) zpusob_jednani_text = db.Column(db.String) - zpusob_jednani_rship = db.relationship("Zpusob_Jednani_Association", back_populates="zpusob_jednani") + zpusob_jednani_rship = db.relationship("Zpusob_Jednani_Association") class Druhy_Podilu(db.Model): __tablename__ = "druhy_podilu" diff --git a/templates/extract-actual.html b/templates/extract-actual.html index d0c3b52..ab19efc 100644 --- a/templates/extract-actual.html +++ b/templates/extract-actual.html @@ -378,7 +378,7 @@ <td>{% if sole_shareholder_notes[i].akcionar_po_id == None %} {% if sole_shareholder_notes[i].jmeno.jmeno != "0" %}{{ sole_shareholder_notes[i].jmeno.jmeno }} {% endif %} {{ sole_shareholder_notes[i].jmeno.prijmeni }}{% if sole_shareholder_notes[i].jmeno.datum_naroz != "" %}, nar. {{ sole_shareholder_notes[i].jmeno.datum_naroz }}{% endif %} {% endif %} - {% if sole_shareholder_notes[i].akcionar_fo_id == None %} {{ sole_shareholder_notes[i].oznaceni_po.nazev }}{% if sole_shareholder_notes[i].oznaceni_po.reg_cislo != 0 %}, reg č. {{ sole_shareholder_notes[i].oznaceni_po.reg_cislo }}{% endif %}{% if sole_shareholder_notes[i].oznaceni_po.ico != 0 %}, IČ {{ sole_shareholder_notes[i].oznaceni_po.ico }}{% endif %} {% endif %} + {% if sole_shareholder_notes[i].akcionar_fo_id == None %} {{ sole_shareholder_notes[i].oznaceni_po.nazev }}{% if sole_shareholder_notes[i].oznaceni_po.reg_cislo != 0 %}, reg č. {{ sole_shareholder_notes[i].oznaceni_po.reg_cislo }}{% endif %}{% if sole_shareholder_notes[i].oznaceni_po.ico != 0 %}, IČ <a href="/{{ sole_shareholder_notes[i].oznaceni_po.ico }}-actual">{{ sole_shareholder_notes[i].oznaceni_po.ico }}</a>{% endif %} {% endif %} <br>{{sole_shareholder_notes[i].adresa}}</td> </tr> {% endfor %} @@ -397,7 +397,7 @@ <td>{% if spolecnici_notes[i].spolecnik_po_id == None %} {% if spolecnici_notes[i].jmeno.jmeno != "0" %}{{ spolecnici_notes[i].jmeno.jmeno }} {% endif %} {{ spolecnici_notes[i].jmeno.prijmeni }}{% if spolecnici_notes[i].jmeno.datum_naroz != "" %}, nar. {{ spolecnici_notes[i].jmeno.datum_naroz }}{% endif %} {% endif %} - {% if spolecnici_notes[i].spolecnik_fo_id == None %} {{ spolecnici_notes[i].oznaceni_po.nazev }}{% if spolecnici_notes[i].oznaceni_po.reg_cislo != 0 %}, reg č. {{ spolecnici_notes[i].oznaceni_po.reg_cislo }}{% endif %}{% if spolecnici_notes[i].oznaceni_po.ico != 0 %}, IČ {{ spolecnici_notes[i].oznaceni_po.ico }}{% endif %} {% endif %} + {% if spolecnici_notes[i].spolecnik_fo_id == None %} {{ spolecnici_notes[i].oznaceni_po.nazev }}{% if spolecnici_notes[i].oznaceni_po.reg_cislo != 0 %}, reg č. {{ spolecnici_notes[i].oznaceni_po.reg_cislo }}{% endif %}{% if spolecnici_notes[i].oznaceni_po.ico != 0 %}, IČ <a href="/{{ spolecnici_notes[i].oznaceni_po.ico }}-actual">{{ spolecnici_notes[i].oznaceni_po.ico }}</a>{% endif %} {% endif %} <br>{{spolecnici_notes[i].adresa}}</td> </tr> {% set spolecnik_podily = [] %} @@ -532,4 +532,8 @@ {% endfor %} +{% if results|length == 0 %} +<p>Nothing found here. <a href = "/">Back to search.</a></p> +{% endif %} + {% include 'footer.html' %}
\ No newline at end of file diff --git a/templates/extract.html b/templates/extract.html index 08dc1af..2bacb06 100644 --- a/templates/extract.html +++ b/templates/extract.html @@ -423,7 +423,7 @@ <td>{{ underlne_style_open|safe }} {% if row.jediny_akcionar[i].akcionar_po_id == None %} {% if row.jediny_akcionar[i].jmeno.jmeno != "0" %}{{ row.jediny_akcionar[i].jmeno.jmeno }} {% endif %} {{ row.jediny_akcionar[i].jmeno.prijmeni }}{% if row.jediny_akcionar[i].jmeno.datum_naroz != "" %}, nar. {{ row.jediny_akcionar[i].jmeno.datum_naroz }}{% endif %} {% endif %} - {% if row.jediny_akcionar[i].akcionar_fo_id == None %} {{ row.jediny_akcionar[i].oznaceni_po.nazev }}{% if row.jediny_akcionar[i].oznaceni_po.reg_cislo != 0 %}, reg č. {{ row.jediny_akcionar[i].oznaceni_po.reg_cislo }}{% endif %}{% if row.jediny_akcionar[i].oznaceni_po.ico != 0 %}, IČ {{ row.jediny_akcionar[i].oznaceni_po.ico }}{% endif %} {% endif %} + {% if row.jediny_akcionar[i].akcionar_fo_id == None %} {{ row.jediny_akcionar[i].oznaceni_po.nazev }}{% if row.jediny_akcionar[i].oznaceni_po.reg_cislo != 0 %}, reg č. {{ row.jediny_akcionar[i].oznaceni_po.reg_cislo }}{% endif %}{% if row.jediny_akcionar[i].oznaceni_po.ico != 0 %}, IČ <a href="/{{ row.jediny_akcionar[i].oznaceni_po.ico }}">{{ row.jediny_akcionar[i].oznaceni_po.ico }}</a>{% endif %} {% endif %} <br>{{row.jediny_akcionar[i].adresa}} {{ underlne_style_close|safe }}</td> <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.jediny_akcionar[i].zapis_datum }} {% if row.jediny_akcionar[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.jediny_akcionar[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> </tr> @@ -451,7 +451,7 @@ <td>{{ underlne_style_open|safe }} {% if row.spolecnici[i].spolecnik_po_id == None %} {% if row.spolecnici[i].jmeno.jmeno != "0" %}{{ row.spolecnici[i].jmeno.jmeno }} {% endif %} {{ row.spolecnici[i].jmeno.prijmeni }}{% if row.spolecnici[i].jmeno.datum_naroz != "" %}, nar. {{ row.spolecnici[i].jmeno.datum_naroz }}{% endif %} {% endif %} - {% if row.spolecnici[i].spolecnik_fo_id == None %} {{ row.spolecnici[i].oznaceni_po.nazev }}{% if row.spolecnici[i].oznaceni_po.reg_cislo != 0 %}, reg č. {{ row.spolecnici[i].oznaceni_po.reg_cislo }}{% endif %}{% if row.spolecnici[i].oznaceni_po.ico != 0 %}, IČ {{ row.spolecnici[i].oznaceni_po.ico }}{% endif %} {% endif %} + {% if row.spolecnici[i].spolecnik_fo_id == None %} {{ row.spolecnici[i].oznaceni_po.nazev }}{% if row.spolecnici[i].oznaceni_po.reg_cislo != 0 %}, reg č. {{ row.spolecnici[i].oznaceni_po.reg_cislo }}{% endif %}{% if row.spolecnici[i].oznaceni_po.ico != 0 %}, IČ <a href="/{{ row.spolecnici[i].oznaceni_po.ico }}">{{ row.spolecnici[i].oznaceni_po.ico }}</a>{% endif %} {% endif %} <br>{{row.spolecnici[i].adresa}} {{ underlne_style_close|safe }}</td> <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.spolecnici[i].zapis_datum }} {% if row.spolecnici[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.spolecnici[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> <!-- Insert individual ownership interests --> @@ -629,4 +629,8 @@ {% endfor %} +{% if results|length == 0 %} +<p>Nothing found here. <a href = "/">Back to search.</a></p> +{% endif %} + {% include 'footer.html' %}
\ No newline at end of file diff --git a/update_db.py b/update_db.py index e5f2caa..1dcb09a 100644 --- a/update_db.py +++ b/update_db.py @@ -616,379 +616,8 @@ def insert_pravnicka_osoba(c, elem, spol_ico, regCislo, nazev): except: pass - - - - - - - - - - - - - - - - - - - -# def find_and_store_address(c, elem): -# try: -# addr = str(adresa(get_SIDLO_v3(elem))) -# insert_address(c, addr) -# address_id = find_address_id(c, addr) -# return address_id -# except Exception as f: -# print(f) - -# def find_address_id(c, addr): -# try: -# anciallary_table_key = c.execute("SELECT id FROM adresy WHERE adresa_text = (?)", (addr,)) -# anciallary_table_key = c.fetchone()[0] -# return anciallary_table_key -# except Exception as f: -# print(f) - - - -# def insert_address(c, addr): -# try: -# c.execute("INSERT into adresy (adresa_text) VALUES (?)", (addr,)) -# except: -# pass - - - - - - - -# def sidlo2(c, elem, primary_sql_key): -# try: -# statNazev = get_prop(elem, ".//statNazev") -# obec = get_prop(elem, ".//obec") -# ulice = get_prop(elem, ".//ulice") -# castObce = get_prop(elem, ".//castObce") -# cisloPo = get_prop(elem, ".//cisloPo") -# cisloOr = get_prop(elem, ".//cisloOr") -# psc = get_prop(elem, ".//psc") -# okres = get_prop(elem, ".//okres") -# adresaText = get_prop(elem, ".//adresaText") -# cisloEv = get_prop(elem, ".//cisloEv") -# cisloText = get_prop(elem, ".//cisloText") -# c.execute("INSERT INTO adresy_v2 (stat, obec, ulice, castObce, cisloPo, cisloOr, psc, okres, komplet_adresa, cisloEv, cisloText, company_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)", (statNazev, obec, ulice, castObce, cisloPo, cisloOr, psc, okres, adresaText, cisloEv, cisloText, primary_sql_key)) -# except: -# pass - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# def insert_primary_company_figures(c, ICO, element, conn): -# insert_instructions = [("nazev","nazev"), ("zapisDatum","zapis"), (".//udaje/Udaj/spisZn/oddil","oddil"), -# (".//udaje/Udaj/spisZn/vlozka","vlozka"),(".//udaje/Udaj/spisZn/soud/kod","soud")] -# for elem in insert_instructions: -# insert_prop(c, get_prop(element, elem[0]), conn, ICO, elem[1]) -# # Override to insert the address -# # insert_prop(c, insert_instructions[-1][0], conn, ICO, insert_instructions[-1][1]) -# return 0 - - - - - - - - - - - - - -# def insert_obec_relation(c, conn, ICO, element, primary_sql_key): -# obec = str(get_prop(element, ".//udaje/Udaj/adresa/obec")) -# # Insert a municipality into a table with municipalites -# try: -# c.execute("INSERT INTO obce (obec_jmeno) VALUES(?)", (obec,)) -# except: -# pass -# # Get municipality sql_id -# try: -# municipality_key = c.execute("SELECT id FROM obce WHERE obec_jmeno = (?)", (obec,)) -# municipality_key = c.fetchone()[0] -# except: -# print("Nepovedlo se") -# # Establish a relational link -# try: -# c.execute("INSERT INTO obec_relation VALUES(?, ?)", (primary_sql_key, municipality_key,)) -# except: -# pass - -# return - -# def zkusit_najit_vsechny_osoby(element): -# stat_list = element.iter('osoba') -# temp_osoby = [] -# for elem in stat_list: -# try: -# osoba_temp = "" -# osoba_temp += get_prop(element, ".//jmeno") + " " -# osoba_temp += get_prop(element, ".//prijmeni") + ", nar. " -# osoba_temp += get_prop(element, ".//narozDatum") -# temp_osoby.append(osoba_temp) -# except: -# pass -# return temp_osoby - -# def zkusit_najit_vsechny_adresy(element): -# stat_list = element.iter('adresa') -# temp_adresy = [] -# for elem in stat_list: -# temp_adresy.append(str(adresa(get_SIDLO_v3(elem)))) -# return temp_adresy - -# def find_business(element): -# subjekt_udaje = element.findall('.//Udaj') -# for udaj in subjekt_udaje: -# udaje_spolecnosti = udaj.findall(".//kod") -# if "PREDMET_PODNIKANI_SEKCE" in udaje_spolecnosti[0].text: -# predmety2 = [elem.text.replace(u'\xa0', u' ') for elem in udaj.iterfind(".//hodnotaText")] -# return predmety2 -# # TODO - Filter areas that are no longer relevant - -# def insert_obec(c, obec, conn, ICO, sql_id): -# try: -# c.execute("INSERT INTO obce (obec_jmeno) VALUES(?)", (obec,)) -# except: -# pass - -# def insert_adresa(c, adresa, conn, ICO, sql_id): -# try: -# c.execute("INSERT INTO adresy (adresa_jmeno) VALUES(?)", (adresa,)) -# except: -# pass - -# def insert_osoba(c, osoba, conn, ICO, sql_id): -# try: -# c.execute("INSERT INTO osoby (osoba_jmeno) VALUES(?)", (osoba,)) -# except: -# pass - - -# def insert_ulice(c, ulice, conn, ICO, sql_id): -# try: -# c.execute("INSERT INTO ulice (ulice_jmeno) VALUES(?)", (ulice,)) -# except: -# pass - -# def insert_prop_v2(c, prop, conn, ICO, column, table, sql_id): -# if prop != None: -# for elem in prop: -# c.execute("INSERT INTO predmety_podnikani (company_id, predmet_podnikani) VALUES(?,?)", (sql_id, elem,)) - - - - - def get_prop(element, prop): try: return element.find(prop).text except: - return "0" - -# def insert_prop(c, prop, conn, ICO, column): -# try: -# c.execute("UPDATE companies SET (%s) = (?) WHERE ico = (?)" % (column), (prop, ICO,)) -# except Exception as e: -# print(e) - -# def get_SIDLO_v2(element): -# address_field = [] -# address_field.append(get_prop(element, ".//udaje/Udaj/adresa/statNazev")) -# address_field.append(get_prop(element, ".//udaje/Udaj/adresa/obec")) -# address_field.append(get_prop(element, ".//udaje/Udaj/adresa/ulice")) -# address_field.append(get_prop(element, ".//udaje/Udaj/adresa/castObce")) -# address_field.append(get_prop(element, ".//udaje/Udaj/adresa/cisloPo")) -# address_field.append(get_prop(element, ".//udaje/Udaj/adresa/cisloOr")) -# address_field.append(get_prop(element, ".//udaje/Udaj/adresa/psc")) -# address_field.append(get_prop(element, ".//udaje/Udaj/adresa/okres")) -# address_field.append(get_prop(element, ".//udaje/Udaj/adresa/adresaText")) -# address_field.append(get_prop(element, ".//udaje/Udaj/adresa/cisloEv")) -# address_field.append(get_prop(element, ".//udaje/Udaj/adresa/cisloText")) -# if address_field[0] == "Česká republika - neztotožněno": -# address_field[0] = "Česká republika" -# for i in range(len(address_field)): -# if address_field[i] == "0": -# address_field[i] = None -# return address_field - -# def get_SIDLO_v3(element): -# address_field = [] -# address_field.append(get_prop(element, ".//statNazev")) -# address_field.append(get_prop(element, ".//obec")) -# address_field.append(get_prop(element, ".//ulice")) -# address_field.append(get_prop(element, ".//castObce")) -# address_field.append(get_prop(element, ".//cisloPo")) -# address_field.append(get_prop(element, ".//cisloOr")) -# address_field.append(get_prop(element, ".//psc")) -# address_field.append(get_prop(element, ".//okres")) -# address_field.append(get_prop(element, ".//adresaText")) -# address_field.append(get_prop(element, ".//cisloEv")) -# address_field.append(get_prop(element, ".//cisloText")) -# if address_field[0] == "Česká republika - neztotožněno": -# address_field[0] = "Česká republika" -# for i in range(len(address_field)): -# if address_field[i] == "0": -# address_field[i] = None -# return address_field - - -# class adresa(object): -# def __init__(self, adresa): -# self.stat = adresa[0] -# self.obec = adresa[1] -# self.ulice = adresa[2] -# self.castObce = adresa[3] -# self.cisloPo = adresa[4] -# self.cisloOr = adresa[5] -# self.psc = adresa[6] -# self.okres = adresa[7] -# self.komplet_adresa = adresa[8] -# self.cisloEv = adresa[9] -# self.cisloText = adresa[10] - -# def __str__ (self): -# try: -# # if self.obec == "-": -# # return("Neznama adresa") -# if self.komplet_adresa != None: -# if self.stat != None: -# return str(self.komplet_adresa + " " + self.stat) -# else: -# return str(self.komplet_adresa) -# # if self.obec == None: -# # return("Neznama adresa") -# if self.cisloText != None: -# if self.ulice == None: -# if self.psc != None: -# return str(self.cisloText + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.psc + " " + self.obec + ", " + self.stat) -# else: -# return str(self.cisloText + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.obec + ", " + self.stat) -# if self.okres == None and self.castObce != None: -# if self.psc != None: -# return str(self.obec + " - " + self.castObce + ", " + self.ulice + " " + self.cisloText + ", PSČ " + self.psc) -# else: -# return str(self.obec + " - " + self.castObce + ", " + self.ulice + " " + self.cisloText) -# if self.okres == None and self.castObce == None and self.psc != None: -# return str(self.obec + ", " + self.ulice + " " + self.cisloText + ", PSČ " + self.psc) -# if self.castObce == None and self.psc == None: -# return str(self.obec + ", " + self.ulice + " " + self.cisloText) -# else: -# if self.psc != None and self.ulice == None: -# return str(self.obec + " " + self.cisloText + " " + "okres " + self.okres + ", PSČ " + self.psc) -# elif self.ulice == None: -# return str(self.obec + " " + self.cisloText + " " + "okres " + self.okres) -# elif self.obec != None and self.ulice != None and self.psc != None: -# return str(self.obec + ", " + self.ulice + " " + self.cisloText + ", PSČ " + self.psc) -# elif self.obec != None and self.ulice != None: -# return str(self.obec + ", " + self.ulice + " " + self.cisloText) -# if self.ulice != None : -# if self.cisloOr != None: -# if self.cisloPo == None: -# return str(self.ulice + " " + self.cisloOr + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.psc + " " + self.obec + ", " + self.stat) -# elif self.psc != None: -# return str(self.ulice + " " + self.cisloPo + "/" + self.cisloOr + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.psc + " " + self.obec + ", " + self.stat) -# else: -# return str(self.ulice + " " + self.cisloPo + "/" + self.cisloOr + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.obec + ", " + self.stat) -# if self.cisloPo == None: -# if self.cisloEv == None: -# if self.psc != None: -# return str(self.obec + ", " + self.ulice + "" + srovnat_obec_cast(self.obec, self.castObce) + ", PSČ " + self.psc + " " + self.stat) -# else: -# return str(self.obec + ", " + self.ulice + "" + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.stat) -# else: -# return str(self.ulice + " č.ev. " + self.cisloEv + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.psc + " " + self.obec + ", " + self.stat) -# else: -# if self.psc != None: -# return str(self.ulice + " " + self.cisloPo + "" + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.psc + " " + self.obec + ", " + self.stat) -# else: -# return str(self.ulice + " " + self.cisloPo + "" + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.obec + ", " + self.stat) - -# if self.cisloPo == None and self.cisloEv != None: -# return str(self.obec + " č.ev. " + self.cisloEv + ", " + self.psc + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.obec + ", " + self.stat) - -# if self.cisloPo != None: -# return str("č.p. " + self.cisloPo + ", " + self.psc + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.obec + ", " + self.stat) - -# if self.cisloPo == None and self.cisloEv == None and self.ulice == None: -# return (self.obec + " " + self.stat) - -# except TypeError: -# temp_adr = [] -# if self.ulice != None: -# temp_adr.append(self.ulice) - -# if self.obec != None: -# temp_adr.append(self.obec) - -# if self.castObce != None: -# temp_adr.append(self.castObce) - -# if self.cisloPo != None: -# temp_adr.append(self.cisloPo) - -# if self.cisloOr != None: -# temp_adr.append(self.cisloOr) - -# if self.psc != None: -# temp_adr.append(self.psc) - -# if self.okres != None: -# temp_adr.append(self.okres) - -# if self.cisloEv != None: -# temp_adr.append(self.cisloEv) - -# if self.cisloText != None: -# temp_adr.append(self.cisloText) - -# if self.stat != None: -# temp_adr.append(self.stat) - -# listToStr = ' '.join([str(elem) for elem in temp_adr]) - -# return listToStr - -# def srovnat_obec_cast(obec, cast_obce): -# if obec == cast_obce: -# return str("") -# elif cast_obce == None: -# return str("") -# else: -# return str(", " + cast_obce)
\ No newline at end of file + return "0"
\ No newline at end of file |