Advertisement
ALENTL

Untitled

Sep 25th, 2022
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import mysql.connector as mc
  2. cnx = mc.connect(host="localhost", user="alen", password="alen", database="joseph_project")
  3.  
  4. cur = cnx.cursor()
  5.  
  6. def connection():
  7. if cnx.is_connected():
  8. return 1
  9.  
  10. c = connection()
  11.  
  12. if c == 1:
  13. print("Electronic Shop System")
  14. print("1. Items")
  15. print("2. Labours")
  16. print("3. Customers")
  17. print("4. Sales")
  18. print("5. Expenses")
  19.  
  20. try:
  21. cur.execute("CREATE TABLE ITEMS(S_NO INT PRIMARY KEY, ITEM VARCHAR(50), AVAILABLE BOOLEAN, STOCK INT, PRICE INT)")
  22. cur.execute("CREATE TABLE LABOURS(NAME VARCHAR(25) PRIMARY KEY, AGE INT, PLACE VARCHAR(40), DEPARTMENT VARCHAR(20))")
  23. cur.execute("CREATE TABLE CUSTOMER(SNO INT PRIMARY KEY, CNAME VARCHAR(50), AGE INT, PLACE VARCHAR(30), ITEM_BOUGHT VARCHAR(25))")
  24. cnx.commit()
  25. except:
  26. print("Table Created")
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement