我有一个用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