我有一個用python編寫的sql。如何將html數據存儲在mysql數據庫中?
cur.execute("INSERT INTO products_details(
title,
description,
price,
currency,
sku,
brand,
colors,
sizes,
actual_url,
meta_title,
meta_keywords,
meta_description,
sizefitcontainer,
designercontainer,
wearwith,
colorthumb,
colorbig,
colormedium,
discount_price,
cat_name)
VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s') ", (
context['product_title'],
context['product_description'],
context['price'],
context['currency'],
context['productCode'],
context['brand_name'],
context['colors'],
context['sizes'],
context['actual_url'],
context['title'],
context['meta_keywords'],
context['meta_description'],
context['sizefitcontainer'],
context['designercontainer'],
context['wearwith'],
context['colorthumb'],
context['colorbig'],
context['colormedium'],
context['discount_price'],
context['cat_name']))
在上面的查詢中有兩個字段designercontainer , and sizefitcontainer
在這我傳遞一些HTML數據在數據庫存儲。 但每次我收到一些錯誤。
(<class '_mysql_exceptions.ProgrammingError'>, ProgrammingError(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 'Cosmic Leggings'',''These cropped KORAL ACTIVEWEAR leggings have iridescent cont' at line 1"), <traceback object at 0x2bc2638>).
我試圖UTF編碼也是這也解決不了這個問題。請告訴我如何寫查詢,以便這兩個領域都可以接受HTML值(用js和css嵌入)。
context is a python dict.
嗨檢查輸入 – user1481793 2014-10-04 16:12:12