[FEA] Initial commit
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
__pycache__/
|
||||||
|
.env
|
||||||
|
venv/
|
||||||
1
app/__init__.py
Normal file
1
app/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .app import app
|
||||||
3
app/app.py
Normal file
3
app/app.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
0
app/schema/__init__.py
Normal file
0
app/schema/__init__.py
Normal file
4
app/schema/base.py
Normal file
4
app/schema/base.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
from sqlalchemy.orm import DeclarativeBase
|
||||||
|
|
||||||
|
class Base(DeclarativeBase):
|
||||||
|
pass
|
||||||
24
app/schema/book.py
Normal file
24
app/schema/book.py
Normal file
@@ -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})"
|
||||||
21
app/schema/tag.py
Normal file
21
app/schema/tag.py
Normal file
@@ -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})"
|
||||||
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
flask
|
||||||
|
sqlalchemy
|
||||||
|
requests
|
||||||
Reference in New Issue
Block a user