質問編集履歴
3
誤字
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -21,32 +21,29 @@
|
|
|
21
21
|
#MySQLへのコネクション作成
|
|
22
22
|
conn = pymysql.connect(RDS_HOST, user=RDS_USERNAME, passwd=RDS_PASS, db=RDS_DBNAME, connect_timeout=5)
|
|
23
23
|
with conn.cursor() as cursor:
|
|
24
|
-
sql_ord_tbl = " SELECT
|
|
24
|
+
sql_ord_tbl = " SELECT ord FROM ORD"
|
|
25
|
-
cursor.execute(
|
|
25
|
+
cursor.execute(sql_tbl)
|
|
26
|
-
|
|
26
|
+
result_tbl = cursor.fetchone()
|
|
27
27
|
|
|
28
|
-
if
|
|
28
|
+
if result_tbl is None:
|
|
29
|
-
sql_if = "SELECT XXX_id, YYY_name FROM
|
|
29
|
+
sql_if = "SELECT XXX_id, YYY_name FROM IF_ORD"
|
|
30
30
|
cursor.execute(sql_if)
|
|
31
|
-
|
|
31
|
+
result_if = cursor.fetchall()
|
|
32
|
-
list(
|
|
32
|
+
list(if_data)
|
|
33
33
|
|
|
34
|
-
sql_insert = "INSERT INTO
|
|
34
|
+
sql_insert = "INSERT INTO TBL_ORD (XXX_id, YYY_name) VALUES (%s,%s)"
|
|
35
|
-
cursor.execute(sql_insert,
|
|
35
|
+
cursor.execute(sql_insert,result_if)
|
|
36
36
|
|
|
37
37
|
else:
|
|
38
38
|
#IFテーブルのIDの最大値を取る
|
|
39
|
-
max_id =
|
|
39
|
+
max_id = result_tbl[0].max()
|
|
40
|
-
sql_if = "SELECT XX_id, YY_name FROM IF_PRD_ORD WHERE
|
|
40
|
+
sql_if = "SELECT XX_id, YY_name FROM IF_PRD_ORD WHERE if_id > max_id"
|
|
41
41
|
cursor.execute(sql_if)
|
|
42
|
-
|
|
42
|
+
if_datas = cursor.fetchall()
|
|
43
|
-
list(
|
|
43
|
+
list(if_datas)
|
|
44
44
|
|
|
45
|
-
sql_insert = "INSERT INTO
|
|
45
|
+
sql_insert = "INSERT INTO TBL_ORD (XXX_id, YYY_name) VALUES (%s,%s)"
|
|
46
|
-
cursor.execute(sql_insert,
|
|
46
|
+
cursor.execute(sql_insert,result_if)
|
|
47
47
|
|
|
48
48
|
conn.commit()
|
|
49
|
-
|
|
50
|
-
except Exception as e:
|
|
51
|
-
print("error")
|
|
52
49
|
```
|
2
コード変更
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
sql_if = "SELECT XXX_id, YYY_name FROM IF_PRD_ORD"
|
|
30
30
|
cursor.execute(sql_if)
|
|
31
31
|
result_if_ord = cursor.fetchall()
|
|
32
|
+
list(if_order_data)
|
|
32
33
|
|
|
33
34
|
sql_insert = "INSERT INTO TBL_PRD_ORD (XXX_id, YYY_name) VALUES (%s,%s)"
|
|
34
35
|
cursor.execute(sql_insert,result_if_ord)
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
sql_if = "SELECT XX_id, YY_name FROM IF_PRD_ORD WHERE if_production_order_id > max_id"
|
|
40
41
|
cursor.execute(sql_if)
|
|
41
42
|
if_order_data = cursor.fetchall()
|
|
43
|
+
list(if_order_data)
|
|
42
44
|
|
|
43
45
|
sql_insert = "INSERT INTO TBL_PRD_ORD (XXX_id, YYY_name) VALUES (%s,%s)"
|
|
44
46
|
cursor.execute(sql_insert,result_if_ord)
|
1
エラー内容を追記
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
sql_ifでデータ取得までは良いですが、sql_insertのところでこけてしまっています。
|
|
5
5
|
色々試してみましたが詰まってしまっているため、お教えいただけるとありがたいです。
|
|
6
6
|
|
|
7
|
+
TypeError: not all arguments converted during string formatting
|
|
7
8
|
|
|
8
|
-
|
|
9
9
|
### 該当のソースコード
|
|
10
10
|
Python3.7.6
|
|
11
11
|
|