1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#!/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
# class Soud(db.Model):
# __tablename__ = "soudy"
# id = db.Column(db.Integer, primary_key=True)
# name = db.Column(db.String)
# def __repr__(self):
# # return "<soud: {}="">".format(self.name)
# return self.name
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')
)
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')
)
pravni_forma_association=db.Table("pravni_formy_relation",
db.Column("company_id", db.Integer, db.ForeignKey("companies.id"), primary_key=True, nullable=False),
db.Column("pravni_forma_id", db.Integer, db.ForeignKey("pravni_formy.id"), nullable=False),
)
class Company(db.Model):
__tablename__ = "companies"
id = db.Column(db.Integer, primary_key=True)
ico = db.Column(db.String)
nazev = db.Column(db.String)
zapis = db.Column(db.String)
sidlo = db.Column(db.String)
oddil = db.Column(db.String)
vlozka = db.Column(db.String)
soud = db.Column(db.String)
obec = db.relationship("Obce", secondary=association_table, backref="companies")
ulice = db.relationship("Ulice", secondary=ulice_association, backref="companies")
pravni_forma = db.relationship("Pravni_Forma", secondary=pravni_forma_association, backref="companies")
insolvence = db.relationship("Insolvency_Events", backref="companies")
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 Pravni_Forma(db.Model):
__tablename__ = "pravni_formy"
id = db.Column(db.Integer, primary_key=True)
pravni_forma = db.Column(db.String)
company_pravni_forma = db.relationship("Company", secondary=pravni_forma_association)
class Insolvency_Events(db.Model):
__tablename__ = "insolvency_events"
id = db.Column(db.Integer, primary_key=True)
company_id = db.Column(db.String, db.ForeignKey("companies.id"))
company = relationship("Company", backref="insolvency_events")
insolvency_event = db.Column(db.String)
# class Association(db.Model):
# __tablename__ = "obce_relation"
# company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), primary_key=True)
# obec_id = db.Column(db.Integer, db.ForeignKey('obce.id'))
# company = relationship("Company", back_populates = "Obce")
# obec = relationship("Obce", back_populates = "Company")
# </soud:>
|