回答編集履歴
1
コード修正
test
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
`executemany`で複数追加できます。
|
2
|
+
|
3
|
+
単一列を追加する場合は、リストの各要素を明示的にタプルにする必要があるようです。
|
4
|
+
|
5
|
+
参考:[I can't get Python's executemany for sqlite3 to work properly](https://stackoverflow.com/questions/5331894/i-cant-get-pythons-executemany-for-sqlite3-to-work-properly)
|
2
6
|
|
3
7
|
```Python
|
4
8
|
|
@@ -18,7 +22,7 @@
|
|
18
22
|
|
19
23
|
sql = 'INSERT INTO docs (content) VALUES (?)'
|
20
24
|
|
21
|
-
c.executemany(sql,
|
25
|
+
c.executemany(sql,[('aaa',),('bbb',),('ccc',)])
|
22
26
|
|
23
27
|
db.commit()
|
24
28
|
|