-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Валидация данных в юзердате #19
Labels
good first issue 👶
Задача подходит для новичков
Comments
grigoriev-semyon
changed the title
Придумать способ валидации данных в юзердате
Валидация данных в юзердате
Sep 4, 2023
|
Еще необходимо написать скрипт SQL, который выдает непрошедшие вариацию записи в БД |
3 tasks
Скрипт для ручной миграции from re import search
from sqlalchemy import create_engine, not_
from sqlalchemy.orm import sessionmaker
from settings import get_settings
from userdata_api.exceptions import ObjectNotFound
from userdata_api.models.db import Info, Param
def create_session():
settings = get_settings()
engine = create_engine(str(settings.DB_DSN))
TestingSessionLocal = sessionmaker(bind=engine)
return TestingSessionLocal()
def validate_info():
dbsession = create_session()
info_list = (
dbsession.query(Info)
.join(Param)
.filter(Param.validation != None, not_(Info.is_deleted))
.order_by(Info.owner_id)
.all()
)
print("Invalid userdata:\n")
for info in info_list:
param = dbsession.query(Param).filter(Param.id == info.param_id).one_or_none()
if not param:
raise ObjectNotFound(Param, info.param_id)
if not search(param.validation, info.value):
print(info, end="\n\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: