Compare commits

..

No commits in common. "master" and "main" have entirely different histories.
master ... main

4 changed files with 15 additions and 26 deletions

View File

@ -24,8 +24,7 @@ SHANDEX_SFTP_PASSWORD = "ST@Pass2024$$"
INSERT_ORDER = """ INSERT_ORDER = """
EXECUTE [staging].[dbo].[shandex_insert_order_detail] EXECUTE [staging].[dbo].[shandex_insert_order_detail]
:customerkey :customer_order_number
,:customer_order_number
,:customer_po ,:customer_po
,:Order_Type ,:Order_Type
,:order_status ,:order_status
@ -35,7 +34,6 @@ INSERT_ORDER = """
,:customer_number ,:customer_number
,:sold_to_name ,:sold_to_name
,:line_number ,:line_number
,:ship_to
,:supplier_part_number ,:supplier_part_number
,:sku ,:sku
,:description ,:description
@ -66,14 +64,15 @@ def retrieve_x12_edi_files_shandex():
hostname=SHANDEX_SFTP_HOST, username=SHANDEX_SFTP_USERNAME, password=SHANDEX_SFTP_PASSWORD hostname=SHANDEX_SFTP_HOST, username=SHANDEX_SFTP_USERNAME, password=SHANDEX_SFTP_PASSWORD
) )
with ssh_client.open_sftp() as sftp_connection: with ssh_client.open_sftp() as sftp_connection:
sftp_connection.chdir("/Stash/Prod/FromShandex/Reports") #TODO update this to Production folder sftp_connection.chdir("/Stash/Test/FromShandex") #TODO update this to Production folder
for filename in sftp_connection.listdir(): for filename in sftp_connection.listdir():
if filename.startswith("Stash_Tea_Order_Data"): if filename.startswith("Stash_Tea_Order_Data"):
sftp_connection.get(filename, INCOMING_DIRECTORY / filename) sftp_connection.get(filename, INCOMING_DIRECTORY / filename)
new_filename = f"/Stash/Prod/FromShandex/Reports/Archive/{filename}" new_filename = f"/Stash/Test/FromShandex/Archive/{filename}"
sftp_connection.rename(filename, new_filename) sftp_connection.rename(filename, new_filename)
def process_file(file): def process_file(file):
#open file
all_data = [] all_data = []
with file.open(encoding="utf-8", newline="") as csv_file: with file.open(encoding="utf-8", newline="") as csv_file:
reader = csv.reader(csv_file) reader = csv.reader(csv_file)
@ -81,7 +80,6 @@ def process_file(file):
for row in reader: for row in reader:
if row: if row:
key_dict = { key_dict = {
"customerkey":row[7] + '_' + row[9],
"customer_order_number":row[0], "customer_order_number":row[0],
"customer_po":row[1], "customer_po":row[1],
"Order_Type":row[2], "Order_Type":row[2],
@ -92,21 +90,22 @@ def process_file(file):
"customer_number":row[7], "customer_number":row[7],
"sold_to_name":row[8], "sold_to_name":row[8],
"line_number":row[9], "line_number":row[9],
"ship_to":row[10], "supplier_part_number":row[10],
"supplier_part_number":row[11], "sku":row[11],
"sku":row[12], "description":row[12],
"description":row[13], "qty_ordered":row[13],
"qty_ordered":row[14], "qty_picked":row[14],
"qty_picked":row[15], "qty_shorted":row[15],
"qty_shorted":row[16], "uom":row[16],
"uom":row[17], "unit_price":row[17],
"unit_price":row[18],
} }
all_data.append(key_dict) all_data.append(key_dict)
if(all_data): if(all_data):
with yamamotoyama.get_connection() as data_base: with yamamotoyama.get_connection() as data_base:
with data_base.transaction(): with data_base.transaction():
data_base.bulk_query(INSERT_ORDER, all_data) data_base.bulk_query(INSERT_ORDER, all_data)
#load vars and insert
#archive
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -1,7 +0,0 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACBV8x5ikQyA6ZgAO2BokIZB13CCFjiQIU8bHf8BXrkVLAAAAJj90RvK/dEb
ygAAAAtzc2gtZWQyNTUxOQAAACBV8x5ikQyA6ZgAO2BokIZB13CCFjiQIU8bHf8BXrkVLA
AAAEBIPcJFMSUHOcXD0G85tKPaaSaUfXoYz/pgoffs+Y4ul1XzHmKRDIDpmAA7YGiQhkHX
cIIWOJAhTxsd/wFeuRUsAAAAEHl1bWlkZGxld2FyZTIwMjMBAgMEBQ==
-----END OPENSSH PRIVATE KEY-----

View File

@ -1 +0,0 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFXzHmKRDIDpmAA7YGiQhkHXcIIWOJAhTxsd/wFeuRUs yumiddleware2023

View File

@ -1,2 +0,0 @@
s-8ade4d252cc44c50b.server.transfer.us-west-1.amazonaws.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIDQlEH17E193o9cOd0azlbI388A2GX4DzCWriLuj+BI+Jsi4Ij6oSKbsfKsqY0oThzdahxvafr1q1RxX4WN7yKGtQ+osOrXaSdSBOfejTJ9Wtr3DI4g6APoK4KX8luo7lYhmdVsNZtYdd2Wz7gIm4hsFtnSzrCyOvYMQ6mzvZQGGb+3V5Ce2wjYb0TjxdDdiacXXtbopVRuPAARqFz8hYMoKsZEyKuMekbErqiaC99ZZXtfmh9ZOJdSIF0N6loMWQaNtdLoyD1Xts3CDAcSg41wSfDYB3mtuIZEC/WNBj57RDuy93IsxH9z4Ak47cCrpChSpXp4pfajJS7W5g+Hyd
ftp.shandex.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDWht+ZlPHMwzohq4gnOTAAdtCt2u7BG/fdONXdvluMopWq8bwTKX0iKV5/7sRIIGimk1zIX19zDGR/5B9BbPFBRrxdKA915L830hj8omdo/ayA7pm/sDE7YdmSzUJ/akaO2KYDqBcpElr0Eb3gKaxy1oJGOR8zcLEffZpmYjMHKuCE6KqooCbn6326yRpl/fUhFK9QKLowIzBpeaQzGeNnGLON6j1bRPtObO0QYykdsb6mMF77ZKcf/kibnAtau2APC6xmDL3LDA6h5bwMs8nrC2Yg094dFPjvmC2FIbgiomtz8bfhLYsjDSE1JMNOUIbyoNvitWX5Zavtp70FnQcv