2017-10-12 2 views
1

enter image description herepymssql - SELECT 작동하지만 UPDATE 내가 pymssql와 파이썬 3.5을 사용하고 있지

import pymssql 
import decimal 

CONN = pymssql.connect(server='1233123123', user='s123', password='sa1231231', database='DBforTEST') 
CURSOR = CONN.cursor() 
"""it is good code. here is no problem""" 
CURSOR.execute("SELECT ttt from test where w=2") 
ROW = CURSOR.fetchone() 
tmp = list() 
tmp.append(ROW) 
if ROW is None: 
    print("table has nothing") 
else: 
    while ROW: 
     ROW = CURSOR.fetchone() 
     tmp.append(ROW) 
print(tmp) 
"""it works!""" 

CURSOR.execute(""" 
       UPDATE test 
       SET 
       w = 16 
       where ttt = 1 
       """) 
"it doesnt works" 

않습니다.

내 코드에서 SELECT 상태가 작동하므로 연결이 완벽하다는 것을 보증 할 수 있습니다.
그러나 UPDATE 상태는 Python에서 작동하지 않습니다.
동일한 코드가 SSMS에서 작동합니다.

무엇이 문제입니까?
SELECT 상태는 읽기 전용이므로 DB는 데이터를 제공 할 수 있지만 UPDATE은 DB를 수정하므로 DB가이를 차단합니다.

어떻게 해결할 수 있습니까?

답변

2
CONN.commit() 

자동 커밋이 설정되지 않은 경우 커밋해야합니다.

관련 문제