Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. import sqlite3
  2. customer_db = sqlite3.connect('C:\\Users\\Saulius\\Desktop\\Customers\\customers.db')#For home use replace "student" with "User name"
  3. c=customer_db.cursor()
  4. #firstname, surname, town, telephone
  5. c.execute("SELECT * FROM customers")
  6. #c.execute('''CREATE TABLE Customers(firstname text,surname text,town text,telephone text)''')
  7.  
  8.  
  9. def main_menu():
  10. print("Welcome to John's Decorating")
  11. print("You have the following options:\n")
  12. print("1) Add a new customer")
  13. print("2) List all customers")
  14. print("3) Add a new quote")
  15. print("4) List all quotations")
  16. print("5) Save customer details")
  17. print("6) Save quotation to file\n")
  18. print("0) Exit")
  19.  
  20. choice = int(input('Select one : '))
  21. if choice == 1:
  22. add_customer()
  23. if choice == 2:
  24. list_all_customers()
  25. if choice == 3:
  26. add_a_quote()
  27. if choice == 4:
  28. list_all_quotations()
  29. if choice == 5:
  30. save_customer_details()
  31. if choice == 6:
  32. save_quotation()
  33. if choice == 0:
  34. print ("Good Bye")
  35. sys.exit()
  36.  
  37. def add_customer():
  38. customer_db = sqlite3.connect('C:\\Users\\Saulius\\Desktop\\Customers\\customers.db')#For home use replace "student" with "User name"
  39. print("Add Customer Selected")
  40. cust_firstname = input("Enter the customers first name: ")
  41. cust_surname = input("Enter the customers surname: ")
  42. cust_town = input("Enter the customers town: ")
  43. cust_telephone = input("Enter the customers telephone number: ")
  44. c.execute("INSERT INTO Customers VALUES (?,?,?,?)",(cust_firstname, cust_surname, cust_town, cust_telephone))
  45. customer_db.commit()
  46. customer_db.close()
  47. print ("Information has been added \nWould you like to add another?\n Y for Yes\n N for No\n")
  48. another = str(input('Add another?:\n'))
  49. if another != "Y" or "y" or "N" or "n":
  50. print("Invalid input try again\n")
  51. print ("Information has been added \nWould you like to add another?\n Y for Yes\n N for No")
  52. another = str(input('Add another?:'))
  53. if another == "Y" or "y":
  54. add_customer()
  55. if another == "N" or "n":
  56. print ("Returning to main menu")
  57. main_menu()
  58. def list_all_customers():
  59. customer_db = sqlite3.connect('C:\\Users\\Saulius\\Desktop\\Customers\\customers.db')#For home use replace "student" with "User name"
  60. c.execute("SELECT * FROM Customers")
  61. all_customers = c.fetchall()
  62. print(all_customers)
  63. main_menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement