Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- customer_db = sqlite3.connect('C:\\Users\\Saulius\\Desktop\\Customers\\customers.db')#For home use replace "student" with "User name"
- c=customer_db.cursor()
- #firstname, surname, town, telephone
- c.execute("SELECT * FROM customers")
- #c.execute('''CREATE TABLE Customers(firstname text,surname text,town text,telephone text)''')
- def main_menu():
- print("Welcome to John's Decorating")
- print("You have the following options:\n")
- print("1) Add a new customer")
- print("2) List all customers")
- print("3) Add a new quote")
- print("4) List all quotations")
- print("5) Save customer details")
- print("6) Save quotation to file\n")
- print("0) Exit")
- choice = int(input('Select one : '))
- if choice == 1:
- add_customer()
- if choice == 2:
- list_all_customers()
- if choice == 3:
- add_a_quote()
- if choice == 4:
- list_all_quotations()
- if choice == 5:
- save_customer_details()
- if choice == 6:
- save_quotation()
- if choice == 0:
- print ("Good Bye")
- sys.exit()
- def add_customer():
- customer_db = sqlite3.connect('C:\\Users\\Saulius\\Desktop\\Customers\\customers.db')#For home use replace "student" with "User name"
- print("Add Customer Selected")
- cust_firstname = input("Enter the customers first name: ")
- cust_surname = input("Enter the customers surname: ")
- cust_town = input("Enter the customers town: ")
- cust_telephone = input("Enter the customers telephone number: ")
- c.execute("INSERT INTO Customers VALUES (?,?,?,?)",(cust_firstname, cust_surname, cust_town, cust_telephone))
- customer_db.commit()
- customer_db.close()
- print ("Information has been added \nWould you like to add another?\n Y for Yes\n N for No\n")
- another = str(input('Add another?:\n'))
- if another != "Y" or "y" or "N" or "n":
- print("Invalid input try again\n")
- print ("Information has been added \nWould you like to add another?\n Y for Yes\n N for No")
- another = str(input('Add another?:'))
- if another == "Y" or "y":
- add_customer()
- if another == "N" or "n":
- print ("Returning to main menu")
- main_menu()
- def list_all_customers():
- customer_db = sqlite3.connect('C:\\Users\\Saulius\\Desktop\\Customers\\customers.db')#For home use replace "student" with "User name"
- c.execute("SELECT * FROM Customers")
- all_customers = c.fetchall()
- print(all_customers)
- main_menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement