1234567891011121314151617181920212223 |
- import time
- from typing import List
- from app import models, schemas
- from sqlalchemy.orm import Session
- def create_jm_hd_relation(db: Session, homework_id: int, item: schemas.JmHomeworkDatasourceRelationCreate):
- db_item = models.JmHomeworkDatasourceRelation(**item.dict(),**{
- "homework_id": homework_id,
- })
- db.add(db_item)
- db.commit()
- db.refresh(db_item)
- return db_item
- def get_jm_relations(db: Session, homework_id: int):
- res: List[models.JmHomeworkDatasourceRelation] = db.query(models.JmHomeworkDatasourceRelation)\
- .filter(models.JmHomeworkDatasourceRelation.homework_id == homework_id).all()
- return res
- def delete_jm_relations(db: Session, homework_id: int):
- db.query(models.JmHomeworkDatasourceRelation)\
- .filter(models.JmHomeworkDatasourceRelation.homework_id == homework_id).delete()
|