Hello,
I have a function that takes in a user's input->stores it in a python variable called 'userQuery' and I would like to take the variable 'userQuery and use it in a select statement to search for parts within my database'
So how do I implement the 'userQuery' variable into the select statement so I can search for parts?
Thanks in advance.
My function right now:
I have a function that takes in a user's input->stores it in a python variable called 'userQuery' and I would like to take the variable 'userQuery and use it in a select statement to search for parts within my database'
So how do I implement the 'userQuery' variable into the select statement so I can search for parts?
Thanks in advance.
My function right now:
#--------------------------------------------------------------- # Search Inventory Items #--------------------------------------------------------------- def searchInventory(): userQuery = input('Item Name: ') #Connect to the inventory database (inventory.db) connection = sqlite3.connect("inventory.db") cursor = connection.cursor() cursor = connection.cursor() #Display all records in the Items Table: cursor.execute('select * from items where Name like %', userQuery, '%') #Get all info from the Items Table result = cursor.fetchall() #Print Results/Inventory in rows print('\n--------------------') print('Search Results') print('--------------------') for row in result: print('\n') print('--------------------') print("Item ID: ", row[0]) print("Item Name: ", row[1]) print("Item Quantity: ", row[2]) print("Item Price: $", row[3]) print("Item Sell Price: $", row[4]) print("Item Description: ", row[5]) print("Item Category: ", row[6]) print("Item Location: ", row[7]) print("Last Updated: ", row[10]) print('--------------------') #Close the connection to the database connection.close() #Go to Admin Menu adminMenu()