mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-24 04:52:33 +02:00
Changes sql-alchemy to version 1.4.49
This commit is contained in:
parent
775b360ff7
commit
67c94cfb7e
@ -24,7 +24,7 @@ repos:
|
||||
- id: pretty-format-json
|
||||
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
# Ruff version.
|
||||
# Ruff version.
|
||||
rev: v0.0.284
|
||||
hooks:
|
||||
- id: ruff
|
||||
@ -59,6 +59,7 @@ repos:
|
||||
- pandas==2.*
|
||||
- pandas-stubs==2.0.*
|
||||
- types-requests
|
||||
- sqlalchemy[mypy]==1.4.49
|
||||
|
||||
- repo: https://github.com/frnmst/md-toc
|
||||
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]
|
||||
disallow_untyped_defs = true
|
||||
exclude = ".ipynb_checkpoints, .mypy_cache, .mytest_cache, build"
|
||||
follow_imports = "silent"
|
||||
plugins = ["sqlalchemy.ext.mypy.plugin"]
|
||||
python_version = "3.11"
|
||||
warn_redudant_casts = true
|
||||
warn_unused_ignores = true
|
||||
@ -27,7 +29,7 @@ readme = "README.md"
|
||||
version = "0.1.0"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
SQLAlchemy = "^2.0.19"
|
||||
SQLAlchemy = {version = "^1.4.46", extras = ["mypy"]}
|
||||
loguru = "^0.7.0"
|
||||
matplotlib = "^3.7.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."""
|
||||
import enum
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import (
|
||||
Column,
|
||||
DateTime,
|
||||
Enum,
|
||||
Float,
|
||||
ForeignKey,
|
||||
ForeignKeyConstraint,
|
||||
Integer,
|
||||
PrimaryKeyConstraint,
|
||||
String,
|
||||
)
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.orm import (
|
||||
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
|
||||
@ -28,9 +21,9 @@ class DistrictCourt(Base): # type: ignore
|
||||
|
||||
__tablename__ = "district_court"
|
||||
|
||||
id = Column(Integer(), primary_key=True)
|
||||
city = Column(String(100), nullable=False)
|
||||
name = Column(String(100), nullable=False)
|
||||
id = sa.Column(sa.Integer, primary_key=True)
|
||||
city = sa.Column(sa.String(100), nullable=False)
|
||||
name = sa.Column(sa.String(100), nullable=False)
|
||||
|
||||
|
||||
class Company(Base): # type: ignore
|
||||
@ -38,18 +31,18 @@ class Company(Base): # type: ignore
|
||||
|
||||
__tablename__ = "company"
|
||||
|
||||
hr = Column(Integer(), nullable=False, primary_key=True)
|
||||
court_id = Column(
|
||||
Integer, ForeignKey("district_court.id"), nullable=False, primary_key=True
|
||||
hr = sa.Column(sa.Integer, nullable=False, primary_key=True)
|
||||
court_id = sa.Column(
|
||||
sa.Integer, sa.ForeignKey("district_court.id"), nullable=False, primary_key=True
|
||||
)
|
||||
name = Column(String(100), nullable=False)
|
||||
street = Column(String(100), nullable=False)
|
||||
zip_code = Column(String(5), nullable=False)
|
||||
city = Column(String(100), nullable=False)
|
||||
sector = Column(String(100), nullable=False)
|
||||
name = sa.Column(sa.String(100), nullable=False)
|
||||
street = sa.Column(sa.String(100), nullable=False)
|
||||
zip_code = sa.Column(sa.String(5), nullable=False)
|
||||
city = sa.Column(sa.String(100), nullable=False)
|
||||
sector = sa.Column(sa.String(100), nullable=False)
|
||||
|
||||
__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"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
company_hr = Column(Integer)
|
||||
company_court = Column(Integer)
|
||||
date = Column(DateTime, default=datetime.now)
|
||||
total_volume = Column(Float)
|
||||
ebit = Column(Float)
|
||||
ebitda = Column(Float)
|
||||
ebit_margin = Column(Float)
|
||||
total_balance = Column(Float)
|
||||
equity = Column(Float)
|
||||
debt = Column(Float)
|
||||
return_on_equity = Column(Float)
|
||||
capital_turnover_rate = Column(Float)
|
||||
id = sa.Column(sa.Integer, primary_key=True)
|
||||
company_hr = sa.Column(sa.Integer, sa.ForeignKey(Company.hr))
|
||||
company_court = sa.Column(sa.Integer, sa.ForeignKey(Company.court_id))
|
||||
date = sa.Column(sa.DateTime(timezone=True), default=datetime.now)
|
||||
total_volume = sa.Column(sa.Float)
|
||||
ebit = sa.Column(sa.Float)
|
||||
ebitda = sa.Column(sa.Float)
|
||||
ebit_margin = sa.Column(sa.Float)
|
||||
total_balance = sa.Column(sa.Float)
|
||||
equity = sa.Column(sa.Float)
|
||||
debt = sa.Column(sa.Float)
|
||||
return_on_equity = sa.Column(sa.Float)
|
||||
capital_turnover_rate = sa.Column(sa.Float)
|
||||
|
||||
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"
|
||||
# company: Mapped[Company] = relationship(Company)
|
||||
|
||||
|
||||
class Sentiment(Base): # type: ignore
|
||||
"""Sentiment."""
|
||||
|
||||
# noinspection SpellCheckingInspection
|
||||
__tablename__ = "sentiment"
|
||||
|
||||
id = Column(Integer(), primary_key=True)
|
||||
# company_hr = mapped_column(ForeignKey("company.hr"))
|
||||
# company_court = mapped_column(ForeignKey("company.court_id"))
|
||||
company_hr = Column(Integer)
|
||||
company_court = Column(Integer)
|
||||
date = Column(DateTime(), default=datetime.now)
|
||||
sentiment_type = Column(
|
||||
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]
|
||||
),
|
||||
id = sa.Column(sa.Integer, primary_key=True)
|
||||
company_hr = sa.Column(sa.Integer, sa.ForeignKey(Company.hr))
|
||||
company_court = sa.Column(sa.Integer, sa.ForeignKey(Company.court_id))
|
||||
date = sa.Column(sa.DateTime(timezone=True), default=datetime.now)
|
||||
sentiment_type = sa.Column(
|
||||
sa.Enum(SentimentTypeEnum),
|
||||
nullable=False,
|
||||
)
|
||||
value = sa.Column(sa.Float(), nullable=False)
|
||||
source = sa.Column(sa.String(100))
|
||||
|
||||
# sentiment = relationship(Company)
|
||||
|
||||
|
||||
# create person object
|
||||
@ -121,21 +94,10 @@ class Person(Base): # type: ignore
|
||||
|
||||
__tablename__ = "person"
|
||||
|
||||
id = Column(Integer(), primary_key=True)
|
||||
name = Column(String(100), nullable=False)
|
||||
surname = Column(String(100), nullable=False)
|
||||
works_for = Column(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"
|
||||
id = sa.Column(sa.Integer, primary_key=True)
|
||||
name = sa.Column(sa.String(100), nullable=False)
|
||||
surname = sa.Column(sa.String(100), nullable=False)
|
||||
works_for = sa.Column(sa.String(100))
|
||||
|
||||
|
||||
# create own relation type and person_relation object
|
||||
@ -144,33 +106,17 @@ class PersonRelation(Base): # type: ignore
|
||||
|
||||
__tablename__ = "person_relation"
|
||||
|
||||
id = Column(Integer(), primary_key=True)
|
||||
# company_hr = mapped_column(ForeignKey("company.hr"))
|
||||
# company_court = mapped_column(ForeignKey("company.court_id"))
|
||||
company_hr = Column(Integer)
|
||||
company_court = Column(Integer)
|
||||
person_id = mapped_column(ForeignKey("person.id"))
|
||||
date_from = Column(DateTime(), default=datetime.now)
|
||||
date_to = Column(DateTime(), default=datetime.now)
|
||||
relation = Column(Enum(RelationTypeEnum), nullable=False) # type: RelationTypeEnum
|
||||
id = sa.Column(sa.Integer, primary_key=True)
|
||||
company_hr = sa.Column(sa.Integer, sa.ForeignKey(Company.hr))
|
||||
company_court = sa.Column(sa.Integer, sa.ForeignKey(Company.court_id))
|
||||
person_id = sa.Column(sa.Integer, sa.ForeignKey(Person.id))
|
||||
date_from = sa.Column(sa.DateTime(timezone=True), default=datetime.now)
|
||||
date_to = sa.Column(sa.DateTime(timezone=True), default=datetime.now)
|
||||
relation = sa.Column(sa.Enum(RelationTypeEnum), nullable=False)
|
||||
|
||||
# company = relationship("Company")
|
||||
# person = relationship("Person", foreign_keys=[person_id])
|
||||
# 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
|
||||
@ -179,14 +125,12 @@ class CompanyRelation(Base): # type: ignore
|
||||
|
||||
__tablename__ = "company_relation"
|
||||
|
||||
id = Column(Integer(), primary_key=True)
|
||||
company1_id = Column(Integer, nullable=False)
|
||||
company2_id = Column(Integer, nullable=False)
|
||||
date_from = Column(DateTime(), default=datetime.now)
|
||||
date_to = Column(DateTime(), default=datetime.now)
|
||||
relation = Column(
|
||||
Enum(RelationTypeCompanyEnum), nullable=False
|
||||
) # type: RelationTypeCompanyEnum
|
||||
id = sa.Column(sa.Integer, primary_key=True)
|
||||
company1_id = sa.Column(sa.Integer, nullable=False)
|
||||
company2_id = sa.Column(sa.Integer, nullable=False)
|
||||
date_from = sa.Column(sa.DateTime(timezone=True), default=datetime.now)
|
||||
date_to = sa.Column(sa.DateTime(timezone=True), default=datetime.now)
|
||||
relation = sa.Column(sa.Enum(RelationTypeCompanyEnum), nullable=False)
|
||||
|
||||
# company = relationship("Company")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user