Подскажите, пожалуйста, как надо работать с кавычками.
Код:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import MySQLdb
# DB connect
db = MySQLdb.connect(host="127.0.0.1", user="user", passwd="pass", db="testdb", charset='utf8')
cursor = db.cursor()
content = "==='==="
sql = """INSERT INTO test( content ) VALUES ( %(content)s )""" % { 'content':content }
cursor.execute(sql)
db.commit()
_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 '==='=== )' at line 1")
CREATE TABLE IF NOT EXISTS `test` (
`content` varchar(256) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;