I'm building a program, where the user input an enterprise's name to get the code running.
I would like the user to pick the enterprise name in a drop down list, but currently i dont have a GUI to make it work.
so for now, I would like to connect the input function to the SQL database enterprises name column.
I already connected SQL to my python code... but how do I connect MySQL to an input function? I want the user to be able to get the information from the database
MY SQL CONNECTION :
import mysql.connector
mydb = mysql.connector.connect(host="localhost", user="nn", passwd="passpass")
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM listedatabase.entreprises_inspecteurs")
for row in mycursor.fetchall():
print (row[1])
mydb.close()
python:
enterprise_name = input()
Thank you for helping
I tried this but no luck:
mydb = mysql.connector.connect(host="localhost", user="nn", passwd="passpass")
mycursor = mydb.cursor()
enterprise_name = input()
mycursor.execute("SELECT n_fabricant FROM listedatabase.entreprises_inspecteurs", (enterprise_name,))
data = mycursor.fetchall()
if data:
code goes there
else:
print('data not found in database')
enterprise_namego?SELECT ... WHERE name=??SUMMARYdescription of an event.WHEREclause, you can't just attach data.