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

質問編集履歴

3

誤字

2021/06/07 05:00

投稿

begginer_pygo
begginer_pygo

スコア16

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 ord_id FROM PRD_ORD"
24
+ sql_ord_tbl = " SELECT ord FROM ORD"
25
- cursor.execute(sql_ord_tbl)
25
+ cursor.execute(sql_tbl)
26
- result_ord_tbl = cursor.fetchone()
26
+ result_tbl = cursor.fetchone()
27
27
 
28
- if result_ord_tbl is None:
28
+ if result_tbl is None:
29
- sql_if = "SELECT XXX_id, YYY_name FROM IF_PRD_ORD"
29
+ sql_if = "SELECT XXX_id, YYY_name FROM IF_ORD"
30
30
  cursor.execute(sql_if)
31
- result_if_ord = cursor.fetchall()
31
+ result_if = cursor.fetchall()
32
-        list(if_order_data)
32
+        list(if_data)
33
33
 
34
- sql_insert = "INSERT INTO TBL_PRD_ORD (XXX_id, YYY_name) VALUES (%s,%s)"
34
+ sql_insert = "INSERT INTO TBL_ORD (XXX_id, YYY_name) VALUES (%s,%s)"
35
- cursor.execute(sql_insert,result_if_ord)
35
+ cursor.execute(sql_insert,result_if)
36
36
 
37
37
  else:
38
38
  #IFテーブルのIDの最大値を取る
39
- max_id = result_ord_tbl[0].max()
39
+ max_id = result_tbl[0].max()
40
- sql_if = "SELECT XX_id, YY_name FROM IF_PRD_ORD WHERE if_production_order_id > max_id"
40
+ sql_if = "SELECT XX_id, YY_name FROM IF_PRD_ORD WHERE if_id > max_id"
41
41
  cursor.execute(sql_if)
42
- if_order_data = cursor.fetchall()
42
+ if_datas = cursor.fetchall()
43
- list(if_order_data)
43
+ list(if_datas)
44
44
 
45
- sql_insert = "INSERT INTO TBL_PRD_ORD (XXX_id, YYY_name) VALUES (%s,%s)"
45
+ sql_insert = "INSERT INTO TBL_ORD (XXX_id, YYY_name) VALUES (%s,%s)"
46
- cursor.execute(sql_insert,result_if_ord)
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

コード変更

2021/06/07 05:00

投稿

begginer_pygo
begginer_pygo

スコア16

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

エラー内容を追記

2021/03/18 12:20

投稿

begginer_pygo
begginer_pygo

スコア16

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