文字列の置換をしようとしています
self.cursor.execute("select (1) from eScraperInterfaceApp_scrapeddata where productURL = '%s' limit 1") % URL
エラー
% でサポートされていないオペランド タイプ: 'long' および 'unicode'
productURL は Unicode なので、どうすれば置き換えることができますか ... 誰か助けてください
文字列の置換をしようとしています
self.cursor.execute("select (1) from eScraperInterfaceApp_scrapeddata where productURL = '%s' limit 1") % URL
エラー
% でサポートされていないオペランド タイプ: 'long' および 'unicode'
productURL は Unicode なので、どうすれば置き換えることができますか ... 誰か助けてください
あなたのコードはやっています:
self.cursor.execute("SQL template") % URL
そのはず:
self.cursor.execute("SQL template" % URL)
の位置を変更)
:
self.cursor.execute("select (1) from eScraperInterfaceApp_scrapeddata where productURL = '%s' limit 1" % URL)
実際にはより正しい方法は、クエリパラメーターを使用することです (SQL インジェクションを防ぐため):
self.cursor.execute("select (1) from eScraperInterfaceApp_scrapeddata where productURL = %s limit 1", (URL,))