mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-22 07:03:56 +02:00
Changes sql-alchemy to version 1.4.49
This commit is contained in:
@ -59,6 +59,7 @@ repos:
|
|||||||
- pandas==2.*
|
- pandas==2.*
|
||||||
- pandas-stubs==2.0.*
|
- pandas-stubs==2.0.*
|
||||||
- types-requests
|
- types-requests
|
||||||
|
- sqlalchemy[mypy]==1.4.49
|
||||||
|
|
||||||
- repo: https://github.com/frnmst/md-toc
|
- repo: https://github.com/frnmst/md-toc
|
||||||
rev: 8.2.0
|
rev: 8.2.0
|
||||||
|
486
poetry.lock
generated
486
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,9 @@ requires = ["poetry-core"]
|
|||||||
|
|
||||||
[tookl.mypy]
|
[tookl.mypy]
|
||||||
disallow_untyped_defs = true
|
disallow_untyped_defs = true
|
||||||
|
exclude = ".ipynb_checkpoints, .mypy_cache, .mytest_cache, build"
|
||||||
follow_imports = "silent"
|
follow_imports = "silent"
|
||||||
|
plugins = ["sqlalchemy.ext.mypy.plugin"]
|
||||||
python_version = "3.11"
|
python_version = "3.11"
|
||||||
warn_redudant_casts = true
|
warn_redudant_casts = true
|
||||||
warn_unused_ignores = true
|
warn_unused_ignores = true
|
||||||
@ -27,7 +29,7 @@ readme = "README.md"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
SQLAlchemy = "^2.0.19"
|
SQLAlchemy = {version = "^1.4.46", extras = ["mypy"]}
|
||||||
loguru = "^0.7.0"
|
loguru = "^0.7.0"
|
||||||
matplotlib = "^3.7.1"
|
matplotlib = "^3.7.1"
|
||||||
plotly = "^5.14.1"
|
plotly = "^5.14.1"
|
||||||
|
31
src/aki_prj23_transparenzregister/utils/enumy_types.py
Normal file
31
src/aki_prj23_transparenzregister/utils/enumy_types.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
"""Collection of enumeration types for the whole project."""
|
||||||
|
import enum
|
||||||
|
|
||||||
|
|
||||||
|
class RelationTypeEnum(enum.Enum):
|
||||||
|
"""RelationTypeEnum."""
|
||||||
|
|
||||||
|
executive = "Executive"
|
||||||
|
auditor = "Auditor"
|
||||||
|
supervisory_board = "Supervisory_Board"
|
||||||
|
managing_director = "Managing_Directory"
|
||||||
|
authorized_representative = "Authorized_Representative"
|
||||||
|
final_auditor = "Final_Auditor"
|
||||||
|
|
||||||
|
|
||||||
|
class SentimentTypeEnum(enum.Enum):
|
||||||
|
"""SentimentTypeEnum."""
|
||||||
|
|
||||||
|
employee_voting = "employee_voting"
|
||||||
|
sustainability = "sustainability"
|
||||||
|
environmental_aspects = "environmental_aspects"
|
||||||
|
perception = "perception"
|
||||||
|
|
||||||
|
|
||||||
|
class RelationTypeCompanyEnum(enum.Enum):
|
||||||
|
"""RelationTypeCompanyEnum."""
|
||||||
|
|
||||||
|
participates_with = "participates_with"
|
||||||
|
has_shares_of = "has_shares_of"
|
||||||
|
is_supplied_by = "is_supplied_by"
|
||||||
|
works_with = "works_with"
|
@ -1,22 +1,15 @@
|
|||||||
"""ORM entities for Prod. DB."""
|
"""ORM entities for Prod. DB."""
|
||||||
import enum
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from sqlalchemy import (
|
import sqlalchemy as sa
|
||||||
Column,
|
|
||||||
DateTime,
|
|
||||||
Enum,
|
|
||||||
Float,
|
|
||||||
ForeignKey,
|
|
||||||
ForeignKeyConstraint,
|
|
||||||
Integer,
|
|
||||||
PrimaryKeyConstraint,
|
|
||||||
String,
|
|
||||||
)
|
|
||||||
from sqlalchemy.orm import (
|
from sqlalchemy.orm import (
|
||||||
declarative_base,
|
declarative_base,
|
||||||
mapped_column,
|
)
|
||||||
relationship,
|
|
||||||
|
from aki_prj23_transparenzregister.utils.enumy_types import (
|
||||||
|
RelationTypeCompanyEnum,
|
||||||
|
RelationTypeEnum,
|
||||||
|
SentimentTypeEnum,
|
||||||
)
|
)
|
||||||
|
|
||||||
# # create an object *district_court* which inherits attributes from Base-class
|
# # create an object *district_court* which inherits attributes from Base-class
|
||||||
@ -28,9 +21,9 @@ class DistrictCourt(Base): # type: ignore
|
|||||||
|
|
||||||
__tablename__ = "district_court"
|
__tablename__ = "district_court"
|
||||||
|
|
||||||
id = Column(Integer(), primary_key=True)
|
id = sa.Column(sa.Integer, primary_key=True)
|
||||||
city = Column(String(100), nullable=False)
|
city = sa.Column(sa.String(100), nullable=False)
|
||||||
name = Column(String(100), nullable=False)
|
name = sa.Column(sa.String(100), nullable=False)
|
||||||
|
|
||||||
|
|
||||||
class Company(Base): # type: ignore
|
class Company(Base): # type: ignore
|
||||||
@ -38,18 +31,18 @@ class Company(Base): # type: ignore
|
|||||||
|
|
||||||
__tablename__ = "company"
|
__tablename__ = "company"
|
||||||
|
|
||||||
hr = Column(Integer(), nullable=False, primary_key=True)
|
hr = sa.Column(sa.Integer, nullable=False, primary_key=True)
|
||||||
court_id = Column(
|
court_id = sa.Column(
|
||||||
Integer, ForeignKey("district_court.id"), nullable=False, primary_key=True
|
sa.Integer, sa.ForeignKey("district_court.id"), nullable=False, primary_key=True
|
||||||
)
|
)
|
||||||
name = Column(String(100), nullable=False)
|
name = sa.Column(sa.String(100), nullable=False)
|
||||||
street = Column(String(100), nullable=False)
|
street = sa.Column(sa.String(100), nullable=False)
|
||||||
zip_code = Column(String(5), nullable=False)
|
zip_code = sa.Column(sa.String(5), nullable=False)
|
||||||
city = Column(String(100), nullable=False)
|
city = sa.Column(sa.String(100), nullable=False)
|
||||||
sector = Column(String(100), nullable=False)
|
sector = sa.Column(sa.String(100), nullable=False)
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
PrimaryKeyConstraint("hr", "court_id", name="pk_company_hr_court"),
|
sa.PrimaryKeyConstraint("hr", "court_id", name="pk_company_hr_court"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -58,61 +51,41 @@ class Finance(Base): # type: ignore
|
|||||||
|
|
||||||
__tablename__ = "finance"
|
__tablename__ = "finance"
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = sa.Column(sa.Integer, primary_key=True)
|
||||||
company_hr = Column(Integer)
|
company_hr = sa.Column(sa.Integer, sa.ForeignKey(Company.hr))
|
||||||
company_court = Column(Integer)
|
company_court = sa.Column(sa.Integer, sa.ForeignKey(Company.court_id))
|
||||||
date = Column(DateTime, default=datetime.now)
|
date = sa.Column(sa.DateTime(timezone=True), default=datetime.now)
|
||||||
total_volume = Column(Float)
|
total_volume = sa.Column(sa.Float)
|
||||||
ebit = Column(Float)
|
ebit = sa.Column(sa.Float)
|
||||||
ebitda = Column(Float)
|
ebitda = sa.Column(sa.Float)
|
||||||
ebit_margin = Column(Float)
|
ebit_margin = sa.Column(sa.Float)
|
||||||
total_balance = Column(Float)
|
total_balance = sa.Column(sa.Float)
|
||||||
equity = Column(Float)
|
equity = sa.Column(sa.Float)
|
||||||
debt = Column(Float)
|
debt = sa.Column(sa.Float)
|
||||||
return_on_equity = Column(Float)
|
return_on_equity = sa.Column(sa.Float)
|
||||||
capital_turnover_rate = Column(Float)
|
capital_turnover_rate = sa.Column(sa.Float)
|
||||||
|
|
||||||
company = relationship("Company")
|
# company: Mapped[Company] = relationship(Company)
|
||||||
|
|
||||||
__table_args__ = (
|
|
||||||
ForeignKeyConstraint(
|
|
||||||
[company_hr, company_court], [Company.hr, Company.court_id]
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class SentimentTypeEnum(enum.Enum):
|
|
||||||
"""SentimentTypeEnum."""
|
|
||||||
|
|
||||||
employee_voting = "employee_voting"
|
|
||||||
sustainability = "sustainability"
|
|
||||||
environmental_aspects = "environmental_aspects"
|
|
||||||
perception = "perception"
|
|
||||||
|
|
||||||
|
|
||||||
class Sentiment(Base): # type: ignore
|
class Sentiment(Base): # type: ignore
|
||||||
"""Sentiment."""
|
"""Sentiment."""
|
||||||
|
|
||||||
|
# noinspection SpellCheckingInspection
|
||||||
__tablename__ = "sentiment"
|
__tablename__ = "sentiment"
|
||||||
|
|
||||||
id = Column(Integer(), primary_key=True)
|
id = sa.Column(sa.Integer, primary_key=True)
|
||||||
# company_hr = mapped_column(ForeignKey("company.hr"))
|
company_hr = sa.Column(sa.Integer, sa.ForeignKey(Company.hr))
|
||||||
# company_court = mapped_column(ForeignKey("company.court_id"))
|
company_court = sa.Column(sa.Integer, sa.ForeignKey(Company.court_id))
|
||||||
company_hr = Column(Integer)
|
date = sa.Column(sa.DateTime(timezone=True), default=datetime.now)
|
||||||
company_court = Column(Integer)
|
sentiment_type = sa.Column(
|
||||||
date = Column(DateTime(), default=datetime.now)
|
sa.Enum(SentimentTypeEnum),
|
||||||
sentiment_type = Column(
|
nullable=False,
|
||||||
Enum(SentimentTypeEnum), nullable=False
|
|
||||||
) # type: SentimentTypeEnum
|
|
||||||
value = Column(Float(), nullable=False)
|
|
||||||
source = Column(String(100))
|
|
||||||
|
|
||||||
sentiment = relationship("Company")
|
|
||||||
__table_args__ = (
|
|
||||||
ForeignKeyConstraint(
|
|
||||||
[company_hr, company_court], [Company.hr, Company.court_id]
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
value = sa.Column(sa.Float(), nullable=False)
|
||||||
|
source = sa.Column(sa.String(100))
|
||||||
|
|
||||||
|
# sentiment = relationship(Company)
|
||||||
|
|
||||||
|
|
||||||
# create person object
|
# create person object
|
||||||
@ -121,21 +94,10 @@ class Person(Base): # type: ignore
|
|||||||
|
|
||||||
__tablename__ = "person"
|
__tablename__ = "person"
|
||||||
|
|
||||||
id = Column(Integer(), primary_key=True)
|
id = sa.Column(sa.Integer, primary_key=True)
|
||||||
name = Column(String(100), nullable=False)
|
name = sa.Column(sa.String(100), nullable=False)
|
||||||
surname = Column(String(100), nullable=False)
|
surname = sa.Column(sa.String(100), nullable=False)
|
||||||
works_for = Column(String(100))
|
works_for = sa.Column(sa.String(100))
|
||||||
|
|
||||||
|
|
||||||
class RelationTypeEnum(enum.Enum):
|
|
||||||
"""RelationTypeEnum."""
|
|
||||||
|
|
||||||
executive = "Executive"
|
|
||||||
auditor = "Auditor"
|
|
||||||
supervisory_board = "Supervisory_Board"
|
|
||||||
managing_director = "Managing_Directory"
|
|
||||||
authorized_representative = "Authorized_Representative"
|
|
||||||
final_auditor = "Final_Auditor"
|
|
||||||
|
|
||||||
|
|
||||||
# create own relation type and person_relation object
|
# create own relation type and person_relation object
|
||||||
@ -144,33 +106,17 @@ class PersonRelation(Base): # type: ignore
|
|||||||
|
|
||||||
__tablename__ = "person_relation"
|
__tablename__ = "person_relation"
|
||||||
|
|
||||||
id = Column(Integer(), primary_key=True)
|
id = sa.Column(sa.Integer, primary_key=True)
|
||||||
# company_hr = mapped_column(ForeignKey("company.hr"))
|
company_hr = sa.Column(sa.Integer, sa.ForeignKey(Company.hr))
|
||||||
# company_court = mapped_column(ForeignKey("company.court_id"))
|
company_court = sa.Column(sa.Integer, sa.ForeignKey(Company.court_id))
|
||||||
company_hr = Column(Integer)
|
person_id = sa.Column(sa.Integer, sa.ForeignKey(Person.id))
|
||||||
company_court = Column(Integer)
|
date_from = sa.Column(sa.DateTime(timezone=True), default=datetime.now)
|
||||||
person_id = mapped_column(ForeignKey("person.id"))
|
date_to = sa.Column(sa.DateTime(timezone=True), default=datetime.now)
|
||||||
date_from = Column(DateTime(), default=datetime.now)
|
relation = sa.Column(sa.Enum(RelationTypeEnum), nullable=False)
|
||||||
date_to = Column(DateTime(), default=datetime.now)
|
|
||||||
relation = Column(Enum(RelationTypeEnum), nullable=False) # type: RelationTypeEnum
|
|
||||||
|
|
||||||
# company = relationship("Company")
|
# company = relationship("Company")
|
||||||
# person = relationship("Person", foreign_keys=[person_id])
|
# person = relationship("Person", foreign_keys=[person_id])
|
||||||
# company = relationship('Company', foreign_keys=[company_hr,company_court])
|
# company = relationship('Company', foreign_keys=[company_hr,company_court])
|
||||||
__table_args__ = (
|
|
||||||
ForeignKeyConstraint(
|
|
||||||
[company_hr, company_court], [Company.hr, Company.court_id]
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class RelationTypeCompanyEnum(enum.Enum):
|
|
||||||
"""RelationTypeCompanyEnum."""
|
|
||||||
|
|
||||||
participates_with = "participates_with"
|
|
||||||
has_shares_of = "has_shares_of"
|
|
||||||
is_supplied_by = "is_supplied_by"
|
|
||||||
works_with = "works_with"
|
|
||||||
|
|
||||||
|
|
||||||
# create own relation type and company_relation object
|
# create own relation type and company_relation object
|
||||||
@ -179,14 +125,12 @@ class CompanyRelation(Base): # type: ignore
|
|||||||
|
|
||||||
__tablename__ = "company_relation"
|
__tablename__ = "company_relation"
|
||||||
|
|
||||||
id = Column(Integer(), primary_key=True)
|
id = sa.Column(sa.Integer, primary_key=True)
|
||||||
company1_id = Column(Integer, nullable=False)
|
company1_id = sa.Column(sa.Integer, nullable=False)
|
||||||
company2_id = Column(Integer, nullable=False)
|
company2_id = sa.Column(sa.Integer, nullable=False)
|
||||||
date_from = Column(DateTime(), default=datetime.now)
|
date_from = sa.Column(sa.DateTime(timezone=True), default=datetime.now)
|
||||||
date_to = Column(DateTime(), default=datetime.now)
|
date_to = sa.Column(sa.DateTime(timezone=True), default=datetime.now)
|
||||||
relation = Column(
|
relation = sa.Column(sa.Enum(RelationTypeCompanyEnum), nullable=False)
|
||||||
Enum(RelationTypeCompanyEnum), nullable=False
|
|
||||||
) # type: RelationTypeCompanyEnum
|
|
||||||
|
|
||||||
# company = relationship("Company")
|
# company = relationship("Company")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user