だから私は先週の金曜日以来、これに取り組んできましたし、このエラーを回避することはできません。1064、「あなたはあなたのSQL構文でエラーが発生している; ...」PythonのMySQLの
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 '[u'161010-035670'] WHERE order_id=87' at line 1" or something along the same lines as this error.
基本的に私のpythonをつかむだろうMySQLデータベースのデータを使用して、SalesForceにSimple-Salesforceを使用してケースを作成し、正しく作成したケースを照会しますが、チケット番号用に作成したカラムのデータベースにそのケース番号を書き戻す必要があります。
現在のコード:
for rowx in xrange(1, sheet.nrows):
SN = sheet.row_values(rowx, start_colx=3, end_colx=None)[0]
print SN
Id = sheet.row_values(rowx, start_colx=6, end_colx=None)[0]
print Id
d = sf.query("SELECT CaseNumber FROM Case WHERE Serial_Number__c ='%s' AND Status = 'New Portal RMA'" % SN)
data = [e["CaseNumber"] for e in d["records"]]
print (data)
try:
con = MySQLdb.connect(user=ur, passwd=pd, host=ht, port=pt, db=db)
cursor = con.cursor()
cursor.execute("UPDATE rma_order SET rma_num=%s WHERE order_id=%s" % (data, Id))
con.commit()
except Error as error:
print(error)
finally:
cursor.close()
con.close()
主な問題は、このコードの行である:
cursor.execute("UPDATE rma_order SET rma_num=%s WHERE order_id=%s" % (data, Id))
私が試したし、 '%s' の差なしとせずにいる、」試してみました... order_id =%s "、(data、Id))と同じエラーが発生しました。 "order_id = 87"を置き換えて、データをcursor.execute( "UPDATE rma_order SET rma_num =%s WHERE order_id = 87"%(data))のままにしておけば、正しく動作し、正しいフォーマットでケース番号を書き込む%sの要素として "Id"を追加するとすぐにエラーが発生します。 %dと同じ結果を試しました。
ご協力いただければ幸いです。
男...私はこの試行錯誤的な方法で10時間以上を費やしました。あなたが「コメントを追加」するのにかかったすべての時間で解決しました。ありがとう、アレクセー –