Professional Documents
Culture Documents
Import Mysql
Import Mysql
TABLE OF CONTENT
1. What is Python?
2. Why Python?
3. What Can Python Do?
4. Interface Python with MySQL
5. Source Code
6. Output
7. Result
8. Bibliography
What Is Python?
It is used for:
Why Python?
Python works on different platforms (Windows,
Mac, Linux, Raspberry Pi, etc).
1. Web Development:
Dynamic Websites.
2. Web Development:
Dynamic Websites
Visualisation
6. Application Development:
Custom Applications
SOURCE CODE:
import mysql.connector as ms
import sys
mycon=
ms.connect(host="localhost",user="root",passwd="root",datab
ase="recipe")
if mycon.is_connected==False:
print("Error in Connecting")
cur=mycon.cursor()
print("=======RECIPE MANAGEMENT
SYSTEM=======")
2. View Recipe
3. Delete Recipe
4. Update Recipe
5.Exit\n''')
if inp==1:
cur.execute(qry)
mycon.commit()
count=cur.rowcount
input()
if view==1:
data=cur.fetchall()
print("------------------------------------------------------------","\n"
"FOOD:",row[0],'\n'
"INGREDIENTS:",row[1],'\n'
"EQUIPMENTS:",row[2],'\n'
"INSTRUCTIONS:",row[3],'\n'
"RATINGS:",row[4],"\n",
"------------------------------------------------------------")
input()
elif view==2:
data=cur.fetchall()
avail=0
if row[0]==l:
avail=1
print("------------------------------------------------------------","\n"
"FOOD:",row[0],'\n'
"INGREDIENTS:",row[1],'\n'
"EQUIPMENTS:",row[2],'\n'
"INSTRUCTIONS:",row[3],'\n'
"RATINGS:",row[4],"\n",
"------------------------------------------------------------")
else:
if avail==0:
print("record not found")
input()
elif inp==3:
print("Deleting a Record")
data=cur.fetchall()
print("------------------------------------------------------------","\n"
"FOOD:",row[0],'\n'
"INGREDIENTS:",row[1],'\n'
"EQUIPMENTS:",row[2],'\n'
"INSTRUCTIONS:",row[3],'\n'
"RATINGS:",row[4],"\n",
"------------------------------------------------------------")
if row[0]==fid:
delete=1
cur.execute(qry)
mycon.commit()
print()
if delete==1:
else:
print()
data=cur.fetchall()
print("-----------------------------------------------------------","\n"
"FOOD:",row[0],'\n'
"INGREDIENTS:",row[1],'\n'
"EQUIPMENTS:",row[2],'\n'
"INSTRUCTIONS:",row[3],'\n'
"RATINGS:",row[4],"\n",
"-----------------------------------------------------------")
input()
elif inp==4:
print("Updating a Record")
cur.execute(qry)
row = cur.fetchone()
count = cur.rowcount
print(count," record is searched successfully.")
print("-----------------------------------------------------------","\
n"
"FOOD:",row[0],'\n'
"INGREDIENTS:",row[1],'\n'
"EQUIPMENTS:",row[2],'\n'
"INSTRUCTIONS:",row[3],'\n'
"RATINGS:",row[4],"\n",
"-----------------------------------------------------------")
if food == '.':
food = row[0]
if ing == '.':
ing = row[1]
if eq == '.':
eq = row[2]
if ins == '.':
ins = row[3]
cur.execute(qry)
mycon.commit()
count = cur.rowcount
input()
#exit database
elif inp==5:
mycon.close()
print("Terminating Program")
sys.exit(0)
else:
input()
OUTPUT:
1. Adding a Record
2. A) Viewing All Record
5. Exit
RESULT:
https://www.google.com
https://www.w3schools.com
https://www.python.org
https://www.wikipedia.org
http://www.ncert.nic.in
_______________________________________________
ACKNOWLEDGEMENT