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이 핵심!
'파이썬' 카테고리의 다른 글
sqlalchemy, session을 활용 특정한 컬럼만 불러오고 update 하기 (0) | 2018.10.04 |
---|---|
python.h 그런 파일이나 디렉터리가 없습니다. (0) | 2018.10.02 |
juptyer notebook, async 사용시 event loop 에러 발생할 경우 (0) | 2018.09.30 |
python) datetime 형변환 관련.. (0) | 2018.09.19 |
패키지 설치지 Microsoft c++ require 14.0 에러가 뜰때 (0) | 2018.09.12 |