SQL 쿼리를 sqlalchemy로 바꾼 방식을 틈날때마다 하나씩 추가하려함


# update


# 예) 게시판 테이블에 회원번호 칼럼이 있고 이를 회원 테이블로부터 가져와서 해당 회원에 맞게 업데이트 해야하는 상황이다
# update bbs set user_num = (select user_num from user where user.id = bbs.id)

#UPDATE table_one SET column_one = (SELECT column_one FROM table_two WHERE table_one.column_two = table_two.column_two)
query = session.query(table_one).filter(table_onw.column_two == table_two.column_two)
query = query.update({"column_one": table_two.column_one}, synchronize_session=False) # synchronize_session이 핵심!

+ Recent posts