Click here to Skip to main content
15,868,340 members
Home / Discussions / Python
   

Python

 
PinnedForum Guidelines - PLEASE READ Pin
Chris Maunder5-Oct-22 12:14
cofounderChris Maunder5-Oct-22 12:14 
Questionnested loop python Pin
MD ARMAN from Durham23-Feb-24 4:17
MD ARMAN from Durham23-Feb-24 4:17 
QuestionDatabase Pin
skmsjh5-Feb-24 15:22
skmsjh5-Feb-24 15:22 
I would like to request assistance with my code, where when inserting a table into the database from Python, the system replies with an error that says that the table is not nonexistent. However, the table is there.

Cafeteria.py
import sqlite3
from Chef_staff import *
conn = sqlite3.connect('Chef__Order.db')
curs = conn.cursor()
MembersID = {'Aria': 'ID001', 'Barston': 'ID002', 'CJ': 'ID003', 'Damarsh': 'ID004', 'Elaine': 'ID005'}
MembersFeedback = {'Aria': 0, 'Barston': 0, 'CJ': 0, 'Damarsh': 0, 'Elaine': 0}
MembersOrder = {'Aria': 0, 'Barston': 0, 'CJ': 0, 'Damarsh': 0, 'Elaine': 0}
Food = {'Burger': 5.00, 'Pancakes': 2.00, 'Sandwiches': 2.50, 'Steak': 10.00, 'Fries': 1.50, 'Tea': 0.50, 'Coffee': 0.75}
FoodRating = {'Burger': 0, 'Pancakes': 0, 'Sandwiches': 0, 'Steak': 0, 'Fries': 0, 'Tea': 0, 'Coffee': 0}
order_no = 0
burger_rate = 0
pancake_rate = 0
sandwich_rate = 0
steak_rate = 0
fries_rate = 0
tea_rate = 0
coffee_rate = 0
accumalated_b = 0
accumalated_p = 0
accumalated_sw = 0
accumalated_st = 0
accumalated_f = 0
accumalated_t = 0
accumalated_c = 0
while True:
order_option = False
login = input('Please enter your member username: ')
for i in MembersID:
if login == i:
while order_option == False:
price = 0
order_no =+ 1
order = int(input('Please select which food you would like to order\n1. Burger\n2. Pancakes\n3. Sandwiches\n4. Steak\n5. Fries\n6. Tea\n7. Coffee\n'))
if order == 1:
amount_order = int(input('How many burgers would you like to order?\n'))
MembersOrder[i] += amount_order
print(f'You have ordered {amount_order} Burger, {login}')
price = Food['Burger'] * amount_order
curs.execute(f'INSERT INTO Progression (OrderNo, ID, Food, Quantity, Price) VALUES ({order_no},{MembersID[i]},"Burger",{amount_order},{price})')
elif order == 2:
amount_order = int(input('How many pancake would you like to order?\n'))
MembersOrder[i] += amount_order
print(f'You have ordered {amount_order} Pancakes, {login}')
price = Food['Pancakes'] * amount_order
curs.execute(f'INSERT INTO Progression (OrderNo, ID, Food, Quantity, Price) VALUES ({order_no},{MembersID[i]},"Pancakes",{amount_order},{price})')
elif order == 3:
amount_order = int(input('How many sandwich would you like to order?\n'))
MembersOrder[i] += amount_order
print(f'You have ordered {amount_order} Sandwiches, {login}')
price = Food['Sandwiches'] * amount_order
curs.execute(f'INSERT INTO Progression.tbl (OrderNo, ID, Food, Quantity, Price) VALUES ({order_no},{MembersID[i]},"Sandwiches",{amount_order},{price})')
elif order == 4:
amount_order = int(input('How many Steak would you like to order?\n'))
MembersOrder[i] += amount_order
print(f'You have ordered {amount_order} Steak, {login}')
price = Food['Steak'] * amount_order
curs.execute(f'INSERT INTO Progression (OrderNo, ID, Food, Quantity, Price) VALUES ({order_no},{MembersID[i]},"Steak",{amount_order},{price})')
elif order == 5:
amount_order = int(input('How many packet of fries would you like to order?\n'))
MembersOrder[i] += amount_order
print(f'You have ordered {amount_order} packet of fries, {login}')
price = Food['Fries'] * amount_order
curs.execute(f'INSERT INTO Progression (OrderNo, ID, Food, Quantity, Price) VALUES ({order_no},{MembersID[i]},"Fries",{amount_order},{price})')
elif order == 6:
amount_order = int(input('How many tea would you like to order?\n'))
MembersOrder[i] += amount_order
print(f'You have ordered {amount_order} tea, {login}')
price = Food['Tea'] * amount_order
curs.execute(f'INSERT INTO Progression (OrderNo, ID, Food, Quantity, Price) VALUES ({order_no},{MembersID[i]},"Tea",{amount_order},{price})')
elif order == 7:
amount_order = int(input('How many coffee would you like to order?\n'))
MembersOrder[i] += amount_order
print(f'You have ordered {amount_order} coffee, {login}')
price = Food['Coffee'] * amount_order
curs.execute(f'INSERT INTO Progression (OrderNo, ID, Food, Quantity, Price) VALUES ({order_no},{MembersID[i]},"Coffee",{amount_order},{price})')
else:
print('Please enter a valid number')
order_option1 = input('Would you like to order more? Y/N\n')
if order_option1 == 'Y':
order_option = False
elif order_option1 == 'N':
order_option = True
option = input('Would you like to give a rating? (Y/N)')
if option == 'Y':
curs.execute(f'INSERT INTO Members (Feedback) VALUE (Feedback + 1)')
selection = int(input('Please select which food to rate\n1. Burger\n2. Pancakes\n3. Sandwiches\n'))
if 1 <= selection <= 7 :
rating = int(input('Please rate your experience from 1 to 5: '))
if rating > 0 and rating < 6:
if selection == 1:
burger_rate += 1
FoodRating['Burger'] = int((accumalated_b + rating) / burger_rate)
curs.execute(f'INSERT INTO Food (Ratings) Value')
elif selection == 2:
pancake_rate += 1
FoodRating['Pancakes'] = int((accumalated_p + rating) / pancake_rate)
elif selection == 3:
sandwich_rate += 1
FoodRating['Sandwiches'] = int((accumalated_sw + rating) / sandwich_rate)
elif selection == 4:
steak_rate += 1
FoodRating['Steak'] = int((accumalated_st + rating) / steak_rate)
elif selection == 5:
fries_rate += 1
FoodRating['Fries'] = int((accumalated_f + rating) / fries_rate)
elif selection == 6:
tea_rate += 1
FoodRating['Tea'] = int((accumalated_t + rating) / tea_rate)
elif selection == 7:
coffee_rate += 1
FoodRating['Coffe'] = int((accumalated_c + rating) / coffee_rate)
else:
print('valid rating is 1 to 5')
print(f'Number of orders ordered by members\n {MembersOrder}')
print(f'Current food rating\n{FoodRating}')

Database table_DB browser
CREATE TABLE "Chef" ( "ChefID" TEXT NOT NULL, "Chefs" TEXT NOT NULL, "Meals cooked No." INTEGER, PRIMARY KEY("ChefID","Chefs") )
CREATE TABLE "Food" ("FoodID" INTEGER, "Food names" TEXT, "Ratings" INTEGER, "Price" INTEGER, PRIMARY KEY("Price", "Food names", "FoodID"))
CREATE TABLE "Members" ("ID" TEXT NOT NULL, "Names" TEXT, "Feedback" INTEGER, PRIMARY KEY("ID","Names"))
CREATE TABLE "Progression" ("OrderNo" INTEGER, "ID" TEXT, "Food" TEXT, "Quantity" INTEGER, "Price" REAL, "Progress" TEXT, FOREIGN KEY("ID") REFERENCES "Members"("ID")) CREATE TABLE sqlite_sequence(name,seq)

Chef_staff.py
ChefID = {'Harlow': 'ID010', 'Benedict': 'ID011', 'Carlson': 'ID012'}
ChefOrder = {'Harlow': 0, 'Benedict': 0, 'Carlson': 0}
AnswerRe: Database Pin
Richard Deeming5-Feb-24 21:26
mveRichard Deeming5-Feb-24 21:26 
Questionto_byte() Pin
utcode2-Feb-24 17:22
utcode2-Feb-24 17:22 
AnswerRe: to_byte() Pin
Richard MacCutchan2-Feb-24 21:55
mveRichard MacCutchan2-Feb-24 21:55 
QuestionI need python code for multiple page pdf extraction Pin
Deepak Vasudevan 20236-Nov-23 17:35
Deepak Vasudevan 20236-Nov-23 17:35 
AnswerRe: I need python code for multiple page pdf extraction Pin
Dave Kreskowiak6-Nov-23 18:06
mveDave Kreskowiak6-Nov-23 18:06 
JokeRe: I need python code for multiple page pdf extraction Pin
Richard Deeming6-Nov-23 21:30
mveRichard Deeming6-Nov-23 21:30 
AnswerRe: I need python code for multiple page pdf extraction Pin
Richard MacCutchan6-Nov-23 21:38
mveRichard MacCutchan6-Nov-23 21:38 
AnswerRe: I need python code for multiple page pdf extraction Pin
Gerry Schmitz8-Nov-23 5:31
mveGerry Schmitz8-Nov-23 5:31 
AnswerRe: I need python code for multiple page pdf extraction Pin
Andre Oosthuizen10-Nov-23 6:36
mveAndre Oosthuizen10-Nov-23 6:36 
QuestionWhat is the difference between "C:\\my folder" and r"C:\my folder" in Python Pin
s yu12-Oct-23 6:44
s yu12-Oct-23 6:44 
AnswerRe: What is the difference between "C:\\my folder" and r"C:\my folder" in Python Pin
Richard Deeming12-Oct-23 21:45
mveRichard Deeming12-Oct-23 21:45 
GeneralRe: What is the difference between "C:\\my folder" and r"C:\my folder" in Python Pin
s yu13-Oct-23 3:17
s yu13-Oct-23 3:17 
AnswerRe: What is the difference between "C:\\my folder" and r"C:\my folder" in Python Pin
Alisha Aalu5-Nov-23 21:49
Alisha Aalu5-Nov-23 21:49 
SuggestionRe: What is the difference between "C:\\my folder" and r"C:\my folder" in Python Pin
Richard Deeming5-Nov-23 22:54
mveRichard Deeming5-Nov-23 22:54 
GeneralRe: What is the difference between "C:\\my folder" and r"C:\my folder" in Python Pin
Alisha Aalu7-Nov-23 21:51
Alisha Aalu7-Nov-23 21:51 
GeneralRe: What is the difference between "C:\\my folder" and r"C:\my folder" in Python Pin
Richard Deeming7-Nov-23 21:56
mveRichard Deeming7-Nov-23 21:56 
QuestionFLAMES game in python Pin
ganga devi 20237-Oct-23 20:20
ganga devi 20237-Oct-23 20:20 
AnswerRe: FLAMES game in python Pin
Richard MacCutchan7-Oct-23 21:38
mveRichard MacCutchan7-Oct-23 21:38 
GeneralRe: FLAMES game in python Pin
ganga devi 20238-Oct-23 8:06
ganga devi 20238-Oct-23 8:06 
QuestionObjectDetectionCoral v1.5.1 - where is python.exe Pin
Richard N6-Oct-23 10:43
Richard N6-Oct-23 10:43 
AnswerRe: ObjectDetectionCoral v1.5.1 - where is python.exe Pin
Richard MacCutchan6-Oct-23 22:29
mveRichard MacCutchan6-Oct-23 22:29 
GeneralRe: ObjectDetectionCoral v1.5.1 - where is python.exe Pin
Richard N7-Oct-23 0:21
Richard N7-Oct-23 0:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.