Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Отрефачить DBHandler и перейти на SQLAlchemy #230

@NekrodNIK

Description

@NekrodNIK

Необходимо провести рефакторинг DBHandler, перенеся всю логику бд именно в слой бд. Что бы не было такого, что функция _check_login почему-то обитает в слое worker и строится поверх DBHandler:

def _check_login(self, login: str) -> bool:
      """
      Checks database for a user with the same login.

      Args:
          login: user login

      Returns:
          True if there is such a user or False if no such user exists.
      """

      try:
          self._db.get_user_by_login(login)
      except DatabaseReadError:
          logger.debug("There is no user in the database")
          return False
      else:
          logger.success("User was found in the database")
          return True

Т.Е. в worker-е должны быть только вызовы методов DBHandler, краткие и лаконичные. А не вот это вот всё)))

Также в рамках этой задачи необходимо провести переход с SQLObjects на SQLAlchemy. Зачем? Так-то в принципе не имеет значения, какую orm юзать, можно её вообще выкинуть и писать чистые SQL запросы. Однако SQLAlchemy имеет большую распространённость и популярность - а из-за чего куда более полную доку. Также у SQLAlchemy есть инструмент миграции - Alembic, а в будущем нам без миграций прямо никак))) Так что вот.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions