From bd135f226506422ec7d7b1044e4a2fec8213d171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ur=C3=ADa?= Date: Sat, 7 Feb 2026 22:11:22 +0100 Subject: [PATCH] [FEA] Initial commit --- .gitignore | 3 +++ app/__init__.py | 1 + app/app.py | 3 +++ app/schema/__init__.py | 0 app/schema/base.py | 4 ++++ app/schema/book.py | 24 ++++++++++++++++++++++++ app/schema/tag.py | 21 +++++++++++++++++++++ main.py | 0 requirements.txt | 3 +++ 9 files changed, 59 insertions(+) create mode 100644 .gitignore create mode 100644 app/__init__.py create mode 100644 app/app.py create mode 100644 app/schema/__init__.py create mode 100644 app/schema/base.py create mode 100644 app/schema/book.py create mode 100644 app/schema/tag.py create mode 100644 main.py create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dcf118f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +__pycache__/ +.env +venv/ \ No newline at end of file diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..5ac2301 --- /dev/null +++ b/app/__init__.py @@ -0,0 +1 @@ +from .app import app \ No newline at end of file diff --git a/app/app.py b/app/app.py new file mode 100644 index 0000000..7232d4a --- /dev/null +++ b/app/app.py @@ -0,0 +1,3 @@ +from flask import Flask + +app = Flask(__name__) \ No newline at end of file diff --git a/app/schema/__init__.py b/app/schema/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/schema/base.py b/app/schema/base.py new file mode 100644 index 0000000..2278416 --- /dev/null +++ b/app/schema/base.py @@ -0,0 +1,4 @@ +from sqlalchemy.orm import DeclarativeBase + +class Base(DeclarativeBase): + pass \ No newline at end of file diff --git a/app/schema/book.py b/app/schema/book.py new file mode 100644 index 0000000..ba9c8a5 --- /dev/null +++ b/app/schema/book.py @@ -0,0 +1,24 @@ +from typing import List +from typing import Optional +from sqlalchemy import String +from sqlalchemy.orm import Mapped +from sqlalchemy.orm import mapped_column +from sqlalchemy.orm import relationship + +from .base import Base + +class Book(Base): + __tablename__ = "book" + id: Mapped[int] = mapped_column(primary_key=True) + name: Mapped[str] = mapped_column(String(255)) + publisher: Mapped[str] = mapped_column(String(255)) + notes: Mapped[str] = mapped_column(String(65656)) + classification: Mapped[int] = mapped_column(primary_key=True) + + tags: Mapped[List["Tags"]] = relationship( + back_populates="book", cascade="all, delete-orphan" + ) + + def __repr__(self) -> str: + return f"Book(id={self.id!r}, name={self.name!r}, publisher={self.publisher!r}," \ + " notes={self.notes!r}, classification={self.classification!r})" \ No newline at end of file diff --git a/app/schema/tag.py b/app/schema/tag.py new file mode 100644 index 0000000..0f4c544 --- /dev/null +++ b/app/schema/tag.py @@ -0,0 +1,21 @@ +from typing import List +from typing import Optional +from sqlalchemy import String +from sqlalchemy.orm import Mapped +from sqlalchemy.orm import mapped_column +from sqlalchemy.orm import relationship + +from .base import Base + +class Tag(Base): + __tablename__ = "tag" + id: Mapped[int] = mapped_column(primary_key=True) + name: Mapped[str] = mapped_column(String(255)) + + books: Mapped[List["Book"]] = relationship( + back_populates="tags", cascade="all, delete-orphan" + ) + + def __repr__(self) -> str: + return f"Book(id={self.id!r}, name={self.name!r}, publisher={self.publisher!r}," \ + " notes={self.notes!r}, classification={self.classification!r})" \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9db933a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +flask +sqlalchemy +requests \ No newline at end of file