Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updating existing Py app
#1
I am a JR .NET developer and have only a couple hours of basic Python training. I have been tasked with updating an existing py application. In the code snippit below I have added the green to the existing function. I have 2 questions. Does there look like any potential errors with my added snippet? And now that the change is made how to I push this to the executable? I am definitely more concerned with saving it to the exe. Confused

 def additem(): results=msSQL.query("SELECT ID FROM TradePulse.dbo.chainauth WHERE ID='{0}';" .format(item_number_entry.get()+LocalDB.settings('chainid'))) ar = results[0] [color=#2ECC71]stmt= "SELECT DeletedItemV.Item FROM DeletedItemV LEFT OUTER JOIN ItemV ON (DeletedItemV.Item = ItemV.Item)WHERE ItemV.Item IS NULL"[/color] if len(ar) > 0: root = tk.Tk() root.withdraw() messagebox.showerror("Chain ID Error", 'Choose a different item number, the entered selected already exists.') [color=#27AE60] # if the item has been deleted and is not active in all warehouses do not allow to add if ar == stmt: root = tk.Tk() root.withdraw() messagebox.showerror("Item ID Error", 'Choose a different item number, the entered selected already has been cancelled.')[/color] if len(ar) == 0: chain=LocalDB.settings('chainid') item=item_number_entry.get() altcode=item_retail_entry.get() if altcode=='AltCode': altcode='' msSQL.queryExecute("INSERT TradePulse.dbo.chainauth (ITEM,CHIND,AltCode,ID) VALUES ({0},'{1}','{2}','{3}');" .format(item,chain,altcode,item+chain)) item_name_txt.set('Item#') item_retail_txt.set('AltCode') item_grid(itemQuery())
Reply
#2
Your indentation appears to be incorrect.
After a function (or method) definition (def) code should be indented 4 spaces.
After conditionals an additional 4 spaces and so on.
Reply
#3
The indentation was messed up due to how I copy pasted. I only added the green code. The rest was already there and working fine. I was able to find a program to turn my .py into .exe however I think I am over my head when trying to put the program back together.
Reply


User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.