Skip to content

Students api develop - #1

Open
Ch1komon wants to merge 20 commits into
students_api_masterfrom
students_api_develop
Open

Ch1komon wants to merge 20 commits into
students_api_masterfrom
students_api_develop

Conversation

@Ch1komon

@Ch1komon Ch1komon commented Jun 7, 2023

Copy link
Copy Markdown
Owner

No description provided.

@Ch1komon
Ch1komon requested a review from vladefr97 June 7, 2023 15:25
Comment thread docker-compose.yml Outdated
dockerfile: Dockerfile
restart: always
environment:
- SQLALCHEMY_DATABASE_URL=postgresql://${DB_USER}:12345@db/${DB_NAME}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше не хардкодить тут переменные 12345@db , все нужно через env файл задавать

Comment thread main.py Outdated
Base = declarative_base()

# Модель студента
class Student(Base):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно вынести в отдельный файл с моделями

Comment thread main.py Outdated
students: List[StudentResponse]

# Подключение к базе данных
SQLALCHEMY_DATABASE_URL = "sqlite:///./test.db"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно вынести в отдельный конфиг файл

Comment thread main.py Outdated
students: List[StudentResponse]

# Подключение к базе данных
SQLALCHEMY_DATABASE_URL = "sqlite:///./test.db"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У тебя же в docker-compose postgres, зачем здесь sqllite?

Comment thread main.py Outdated

# API эндпоинт для создания студента
@app.post("/students/")
def create_student(student: StudentCreate):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно сделать один или несколько отдельных файлов с апишками

Comment thread main.py Outdated
group = db.query(Group).filter(Group.id == group_id).first()
if not group:
raise HTTPException(status_code=404, detail="Group not found")
return {"id": group.id, "name": group.name}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Возвращай pydantic схемы вместо словарей

@Ch1komon
Ch1komon requested a review from vladefr97 June 8, 2023 06:48
Comment thread .env
@@ -0,0 +1,5 @@
DB_USER=postgres

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.env нельзя в репозиторий заливать, там обычно секреты хранятся

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants