2017-03-29 1 views
0

내 코드입니다파이썬 MySQL의 : 오류 데이터를 삽입 여기

qry = " INSERT INTO transactions(transaction_id,listing_id) VALUES ('%s','%s')" 
cursor.execute(qry, ('123', '456',)) 
db_con.commit() 

나는 점점 오전 오류 : 당신은 SQL 매개 변수를 사용하는

(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '123'',''456'')' at line 1") 
+0

나는이'VALUES (% s의 % s의) '있어야하는데 생각 – khelwood

+0

는 @khelwood 맞습니다 . – Rafael

답변

3

(야호!), 그 을 이미 적절한 돌봐 인용 부호. 기본적으로 값을 큰 따옴표로 묶었습니다. 쿼리에서 따옴표를 제거

qry = " INSERT INTO transactions(transaction_id,listing_id) VALUES (%s,%s)" 
0

쿼리에서 double-quoted 따옴표를 제거

qry = " INSERT INTO transactions(transaction_id,listing_id) VALUES (%s,%s)"