質問するログイン新規登録

回答編集履歴

2

連番を付与

2019/02/17 14:44

投稿

firedfly
firedfly

スコア1133

answer CHANGED
@@ -3,8 +3,7 @@
3
3
  手元で実行したところ `no such table: acc_data` は発生しませんでした。
4
4
  以下、3点修正してデータが登録されるところまで確認しました。
5
5
 
6
- 1. `aac_date ` → `acc_date `
6
+ 1`aac_date ` → `acc_date `
7
-
8
7
  ```Python
9
8
  ddl = """
10
9
  CREATE TABLE acc_data
@@ -17,7 +16,7 @@
17
16
  """
18
17
  ```
19
18
 
20
- 1. item_codeを追加
19
+ 2.item_codeを追加
21
20
 
22
21
  ```Python
23
22
  c.execute(ddl)
@@ -27,7 +26,7 @@
27
26
  c.execute("COMMIT;")
28
27
  ```
29
28
 
30
- 1. `[{}]` → `{}`
29
+ 3.`[{}]` → `{}`
31
30
 
32
31
  ```Python
33
32
  c.execute("""

1

item_codeが数値だったので微修正

2019/02/17 14:44

投稿

firedfly
firedfly

スコア1133

answer CHANGED
@@ -27,12 +27,12 @@
27
27
  c.execute("COMMIT;")
28
28
  ```
29
29
 
30
- 1. `[{}]` → `'{}'`
30
+ 1. `[{}]` → `{}`
31
31
 
32
32
  ```Python
33
33
  c.execute("""
34
34
  INSERT INTO acc_data(acc_date,item_code,amount)
35
- VALUES('{}','{}',{});
35
+ VALUES('{}',{},{});
36
36
  """.format(acc_date, item_code, amount))
37
37
  ```
38
38
 
@@ -92,7 +92,7 @@
92
92
  try:
93
93
  c.execute("""
94
94
  INSERT INTO acc_data(acc_date,item_code,amount)
95
- VALUES('{}','{}',{});
95
+ VALUES('{}',{},{});
96
96
  """.format(acc_date,item_code,amount))
97
97
  c.execute("COMMIT;")
98
98
  print("1件登録しました。")