pymysql.err.ProgrammingError: (1064)(字符串轉譯問題)


代碼:

sql = "insert into dm_copy(演出類型,演出場館,劇目名稱,演出地點,演出時間,演出票價,演出團體,創建時間, url)values('%s','%s','%s','%s','%s','%s','%s','%s','%s')" % (category, venue, name, city, showtim, prices[:-1], actor, Creation_time, p_url)

 

問題是:

pymysql.err.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 'tWe','2018/07/09 09:33','https://piao.damai.cn/155901.html')' at line 1")

原因可能是actor值

   有引號

 

 

解決方式

pymysql.escape_string()

 

代碼:

sql = "insert into dm_copy(演出類型,演出場館,劇目名稱,演出地點,演出時間,演出票價,演出團體,創建時間, url)values('%s','%s','%s','%s','%s','%s','%s','%s','%s')" % (category, venue, name, city, showtim, prices[:-1], pymysql.escape_string(actor), Creation_time, p_url)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM