wip: add import endpoint

This commit is contained in:
Jakub Miazek
2024-02-17 08:40:49 +01:00
parent cd3ce997d8
commit 101fa05515
3 changed files with 42 additions and 6 deletions

View File

@@ -63,6 +63,7 @@ class Wordform(Base):
- `occurrences` (int): The number of occurrences of the word form.
"""
__tablename__ = "wordform"
__table_args__ = (PrimaryKeyConstraint("id", name="wordform_pkey"), {"schema": "shakespeare"})
@@ -133,6 +134,7 @@ class Chapter(Base):
- `paragraph` (list[Paragraph]): The paragraphs associated with the chapter.
"""
__tablename__ = "chapter"
__table_args__ = (
ForeignKeyConstraint(["work_id"], ["shakespeare.work.id"], name="chapter_work_id_fkey"),
@@ -193,6 +195,7 @@ class Paragraph(Base):
- `find(cls, db_session: AsyncSession, character: str) -> List[Paragraph]`: A class method that finds paragraphs associated with a specific character. It takes a database session and the name of the character as arguments, and returns a list of matching paragraphs.
"""
__tablename__ = "paragraph"
__table_args__ = (
ForeignKeyConstraint(["character_id"], ["shakespeare.character.id"], name="paragraph_character_id_fkey"),

View File

@@ -27,11 +27,7 @@ class Stuff(Base):
:param name:
:return:
"""
stmt = (
select(cls)
.options(joinedload(cls.nonsense))
.where(cls.name == name)
)
stmt = select(cls).options(joinedload(cls.nonsense)).where(cls.name == name)
result = await db_session.execute(stmt)
instance = result.scalars().first()
if instance is None: