我需要在 MySql db 中插入一个包含双引号的值:
import MySQLdb
cursor = db.cursor()
sql_pattern = 'INSERT INTO Table(column1, column2, column3....) VALUES("{0}".....)'
data_object_array = get_data_object_array()
for item in data_object_array():
sql = sql_pattern.format(item["attr1"], item["attr2"]....)
cursor.execute(sql)
我有一个错误
_mysql_exceptions.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 \'data" fdsfds5454 "data2"")\' at line 1')
"data" fdsfds5454 "data2"
包含的数据在哪里item["attr1"]
我该如何摆脱它?