Commit 8c04b90c by 岳巧源

sql

parent a5fcf3de
Showing with 15 additions and 3 deletions
...@@ -95,15 +95,27 @@ def migrate_from_lie_scm_order(): ...@@ -95,15 +95,27 @@ def migrate_from_lie_scm_order():
if len(str(value_arr[i])) == 0: if len(str(value_arr[i])) == 0:
value_str = value_str + "''" + ", " value_str = value_str + "''" + ", "
continue continue
value_str = value_str + str(value_arr[i]) + ", " value_str = value_str + "'" +str(value_arr[i]) + "'" + ", "
else: else:
if len(str(value_arr[i])) == 0: if len(str(value_arr[i])) == 0:
value_str = value_str + "''" value_str = value_str + "''"
continue continue
value_str = value_str + str(value_arr[i]) value_str = value_str + "'" + str(value_arr[i]) + "'"
insert_sql = "insert into lie_shipping_intermediate_data (" + item_str + ") " + "values (" + value_str + ")" insert_sql = "insert into lie_shipping_intermediate_data (" + item_str + ") " + "values (" + value_str + ")"
#判断 goods_name + warehouse_receipt_sn 的组合是否出现过 没出现就
if len(str(goods_name)) != 0 and len(str(warehouse_receipt_sn)) != 0: #这两个字段不为空值
sql5 = "select id from lie_shipping_intermediate_data where goods_name = " + "'" +str(goods_name) + "'" + " and " + "warehouse_receipt_sn = " + "'" + str(warehouse_receipt_sn) + "'"
cursor.execute(sql5)
result5 = cursor.fetchall()
if len(result5) != 0:
continue #组合已存在 跳过插入
print(insert_sql) print(insert_sql)
try:
cursor.execute(insert_sql)
db.commit()
except Exception as e:
db.rollback()
print(e)
if __name__ == '__main__': if __name__ == '__main__':
migrate_from_lie_scm_order() migrate_from_lie_scm_order()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment