回答編集履歴

1

新たなエラーについて追記

2017/12/04 08:31

投稿

can110
can110

スコア38262

test CHANGED
@@ -3,3 +3,11 @@
3
3
  `cur.execute('~ID=%d',(int(a),))`または``cur.execute('~ID=%d',[int(a)])``と修正ください(動作未検証)
4
4
 
5
5
  参考:[TypeError: 'int' object is not iterable - Python](https://stackoverflow.com/questions/28365580/typeerror-int-object-is-not-iterable-python)
6
+
7
+
8
+
9
+ `MySQLdb`の制限なのか分かりませんが、SQL文中のパラメータ指定では`%s`しか使えないようです。
10
+
11
+ よって`cur.execute('~ID=%s',(a,))`のように`%s`で指定し`(a,)`のように`a`は`str`のままのタプルとして渡してみてください(動作未検証)
12
+
13
+ 参考:[Python MySQLdb issues (TypeError: %d format: a number is required, not str)](https://stackoverflow.com/questions/5785154/python-mysqldb-issues-typeerror-d-format-a-number-is-required-not-str)