0

i try working mysql in scrapy, but mysql always report error

pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '['\n 专升本重要吗?要不要准备专升本?\n ' at line 1")

sql = "INSERT INTO crawler_sohu(Title,Content,images,insert_Time,text_Creat_Time) VALUES({},{},{},{},{})".format(
    item['title'], item['content'], item['images'], item['insert_time'], item['text_creat_time'])
self.cursor.execute(sql)
self.db_conn.commit()
Dharman
  • 26,923
  • 21
  • 73
  • 125
alex
  • 1
  • The problem is called SQL injection. You are formatting the values into the SQL directly. Instead put placeholders in SQL and then pass values in `execute` – Dharman Jul 21 '21 at 16:31

0 Answers0