Apr-29-2022, 10:31 PM
Hello,
So I'm working on an inventory system for myself to keep track of the items I have.
I made a template for a database where all the info for the items will be stored (It's formatted to be a dictionary).
My questions is: will this work for an inventory system? What I mean is will I be able to search for items by name, add new items (keeping the same format: name, price, category, quantity, description, and other field I might want to add in later), view/modify the info, and sort items by category.
If this is possible, how would I make it so I can modify this database and link it to my main script?
(Right now I have a menu for my inventory system that askes if I want to add an item, remove an item, and update an item)
My Dict Database:
So I'm working on an inventory system for myself to keep track of the items I have.
I made a template for a database where all the info for the items will be stored (It's formatted to be a dictionary).
My questions is: will this work for an inventory system? What I mean is will I be able to search for items by name, add new items (keeping the same format: name, price, category, quantity, description, and other field I might want to add in later), view/modify the info, and sort items by category.
If this is possible, how would I make it so I can modify this database and link it to my main script?
(Right now I have a menu for my inventory system that askes if I want to add an item, remove an item, and update an item)
My Dict Database:
# A dictionary to store data items = {1001: {"name": "MG996R Servo", "price": 3, "category": "Motors", "quantity": 10, "Torque (kg/cm)" : 11, "Description" : "A standard servo...", "last updated": "04/29/2021"}, 1002: {"name": "16 Awg Wire", "price": 10, "category": "Wires", "quantity": 2, "length (ft)" : 20, "Description" : "N/A", "last updated": "04/29/2021"}, 1003: {"name": "1/2 inch Pipe", "price": 15, "category": "Pipes", "quantity": 4, "length (ft)": 3, "Description" : "A metal pipe", "last updated": "04/29/2021"}, 1004: {"name": "L16", "price": 0.60, "category": "Small Items", "quantity": 50, "Description" : "N/A" , "last updated": "04/29/2021"}, 1005: {"name": "100ohm Resistor", "price": 0.14, "category": "Electronics", "quantity": 100, "Description" : "Brown Black Brown Gold", "last updated": "04/29/2021"}, }My Inventory menu/main script:
#--------------------------------------------------------------- #Overview #--------------------------------------------------------------- #User is prompted to a login screen #User enters thier name #If their name is in the database they may access the program #User is then taken to the main menu #From there they can checkout a part, #Return a part, #Search for a part, #And view all the parts in stock #Admins can: #Add new items, #Delete items, #Update items, #And view everything in stock #--------------------------------------------------------------- #--------------------------------------------------------------- # Login Menu #--------------------------------------------------------------- def login(): while True: print('=============================\n''\tLogin\n''=============================') user = input("Enter your name (Case Sensitive): ") password = int(input("Enter your password: ")) #If the credentials are validated -> Run validate function -> Go to according menu #Else -> Print error message and show login screen again if validate(user, password): break else: print('You are not registered to use this program') #--------------------------------------------------------------- #--------------------------------------------------------------- # Validate Function -> Validates user #--------------------------------------------------------------- #Pass in user and password variables from login function #Check if the user is valid (registered in database) -> Give access to inventory program #If user is not valid -> return to login #-->TODO: Write the user and current date to a file to keep track of logins def validate(user, password): if StandardUsers().get(user) == password: print('Success! You are now logged in as: ' + user) mainMenu() return True if SuperUsers().get(user) == password: print('Success! You are now logged in as: ' + user) adminMenu() else: print('You are not registered to use this program') login() #--------------------------------------------------------------- #--------------------------------------------------------------- # Admin Menu #--------------------------------------------------------------- def adminMenu(): print('=============================') print('= Inventory Admin Menu =') print('=============================') print('(1) Add New Item to Inventory') print('(2) Remove Item from Inventory') print('(3) Update Inventory') print('(4) Search Item in Inventory') print('(5) Print Inventory Report') print('(6) Log Out') print('(Q) Quit') CHOICE = input("Enter choice: ") adminMenuSelection(CHOICE) def adminMenuSelection(CHOICE): if CHOICE == '1': #Call add item function elif CHOICE == '2': #Call remove item function elif CHOICE == '3': #Call update item function elif CHOICE == '4': #Call search item function elif CHOICE == '5': #Call print item function elif CHOICE == '6': login() elif CHOICE == 'q' or CHOICE == 'Q': exit() #---------------------------------------------------------------