Skip to content

Commit

Permalink
Help
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgyOm committed Jul 26, 2023
1 parent 9d69bc2 commit 599cd95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from sqlalchemy import (Column, DateTime, Integer, String, create_engine, func, )
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import sessionmaker #Что такое sqlalchemy и почему стоит точка orm?

PG_DSN = 'postgresql://POSTGRES_USER:POSTGRES_PASSWORD@localhost:5432/POSTGRES_DB'
engine = create_engine(PG_DSN)
Base = declarative_base()
Session = sessionmaker(bind=engine)


class AdModel(Base):
__tablename__ = 'advertisements'
class AdModel(Base): #Что такое class? Почему в скобочках Base?
__tablename__ = 'advertisements' #Почему тут два нижних подчеркиваний?

id = Column(Integer, primary_key=True)
title = Column(String, index=True, nullable=False)
Expand Down
2 changes: 1 addition & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CreateAdModel(pydantic.BaseModel):
description: str
owner: str

@pydantic.validator("title")
@pydantic.validator("title") #Что такое собачка?
def min_max_length(cls, value: str):
if 1 > len(value) > 70:
raise ValueError('Title should be from 1 to 70 characters')
Expand Down

0 comments on commit 599cd95

Please sign in to comment.