[WIP] Testing and reformuling
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
from .base import Base
|
||||
from .env import Env
|
||||
from .library import Library
|
||||
from .path import Path
|
||||
@@ -1,6 +1,7 @@
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
from sqlalchemy import String
|
||||
from sqlalchemy import ForeignKey
|
||||
from sqlalchemy.orm import Mapped
|
||||
from sqlalchemy.orm import mapped_column
|
||||
from sqlalchemy.orm import relationship
|
||||
@@ -13,9 +14,8 @@ class Env(Base):
|
||||
key: Mapped[str] = mapped_column(String(255))
|
||||
value: Mapped[str] = mapped_column(String(65656))
|
||||
|
||||
libraries: Mapped[List["Library"]] = relationship(
|
||||
back_populates="libraries", cascade="all, delete-orphan"
|
||||
)
|
||||
library_id: Mapped[int] = mapped_column(ForeignKey("library.id"))
|
||||
library: Mapped[int] = relationship("Library", back_populates="envs")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"Book(id={self.id!r}, name={self.name!r}, publisher={self.publisher!r}," \
|
||||
|
||||
@@ -7,17 +7,21 @@ from sqlalchemy.orm import relationship
|
||||
|
||||
from .base import Base
|
||||
|
||||
class LibraryConfig(Base):
|
||||
__tablename__ = "library_config"
|
||||
class Library(Base):
|
||||
__tablename__ = "library"
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(255))
|
||||
notes: Mapped[str] = mapped_column(String(65656))
|
||||
connection_string = Mapped[str] = mapped_column(String(65656))
|
||||
connection_string: Mapped[str] = mapped_column(String(65656))
|
||||
|
||||
env: Mapped[List["Env"]] = relationship(
|
||||
back_populates="env", cascade="all, delete-orphan"
|
||||
envs: Mapped[List["Env"]] = relationship(
|
||||
back_populates="library", cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
paths: Mapped[List["Path"]] = relationship(
|
||||
back_populates="library", 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})"
|
||||
return f"Library(id={self.id!r}, name={self.name!r}, notes={self.notes!r}," \
|
||||
f" connection_string={self.connection_string!r})"
|
||||
21
app/schema/config/path.py
Normal file
21
app/schema/config/path.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
from sqlalchemy import String
|
||||
from sqlalchemy import ForeignKey
|
||||
from sqlalchemy.orm import Mapped
|
||||
from sqlalchemy.orm import mapped_column
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from .base import Base
|
||||
|
||||
class Path(Base):
|
||||
__tablename__ = "path"
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
path: Mapped[str] = mapped_column(String(65656))
|
||||
|
||||
library_id: Mapped[int] = mapped_column(ForeignKey("library.id"))
|
||||
library: Mapped[int] = relationship("Library", back_populates="paths")
|
||||
|
||||
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})"
|
||||
Reference in New Issue
Block a user