Question

Follow a youtube video making a hospital manage system, everything's right, but at the last part...

Follow a youtube video making a hospital manage system, everything's right, but at the last part add database ,it keeps on showing 'table appointments has no column named name'.

How to fix it? Thanks!

from tkinter import *
import sqlite3
import tkinter.messagebox

conn = sqlite3.connect('database.db')
c = conn.cursor()

class Application:
def __init__(self,master):
self.master = master

self.left = Frame(master,width = 800,height = 720,bg = 'lightgreen')
self.left.pack()
self.right = Frame(master,width = 400,height = 720,bg = 'steelblue')
self.right.pack()
  
self.heading = Label(self.left,text = 'ABC Hospital Appointments',font = 'arial 40 bold',fg = 'black',bg = 'lightgreen')
self.heading.place(x = 0,y= 0)
self.name = Label(self.left,text = 'Patient\'s name',fg = 'black',bg = 'lightgreen')
self.name.place(x= 0,y = 100)
self.age = Label(self.left,text = 'Age',fg = 'black',bg = 'lightgreen')
self.age.place(x= 0,y = 140)
self.gender = Label(self.left,text = 'Gender',fg = 'black',bg = 'lightgreen')
self.gender.place(x= 0,y = 180)
self.location = Label(self.left,text = 'Location',fg = 'black',bg = 'lightgreen')
self.location.place(x= 0,y = 220)
self.time = Label(self.left,text = 'Appointment time',fg = 'black',bg = 'lightgreen')
self.time.place(x= 0,y = 260)
  
self.name_ent = Entry(self.left,width = 30)
self.name_ent.place(x = 250,y = 100)
self.age_ent = Entry(self.left,width = 30)
self.age_ent.place(x = 250,y = 140)
self.gender_ent = Entry(self.left,width = 30)
self.gender_ent.place(x = 250,y = 180)
self.location_ent = Entry(self.left,width = 30)
self.location_ent.place(x = 250,y = 220)
self.time_ent = Entry(self.left,width = 30)
self.time_ent.place(x = 250,y = 260)

self.submit = Button(self.left,text = 'Add Appointment',width = 20,height = 3,command = self.add_appointment)
self.submit.place(x = 300,y = 350)

self.name_ent.focus()

def add_appointment(self):
self.val1 = self.name_ent.get()
self.val2 = self.age_ent.get()
self.val3 = self.gender_ent.get()
self.val4 = self.location_ent.get()
self.val5 = self.time_ent.get()

if self.val1 == '' or self.val2 == '' or self.val3 == '' or self.val4 == '' or self.val5 == '' :
tkinter.messagebox.showinfo('Warning','Please fill up all boxes')
else:
sql = 'INSERT INTO appointments (name,age,gender,location,scheduled_time) VALUES (?,?,?,?,?)'
c.execute(sql,(self.val1,self.val2,self.val3,self.val4,self.val5))
conn.commit()
tkinter.messagebox.showinfo('Success','Appointment added')
  

  
root = Tk()
b = Application(root)
root.geometry('1200x720+0+0')
root.resizable(False,False)

root.mainloop()
  
  
  

Homework Answers

Answer #1

As per the error message, "table appointments has no column named name", the "appointments" table in the "database.dbo" database missing the column with name as "name".

The "appointments" table should contain the following column names

In the above table, the "name" is the first column, "age" is the second column and so on.

So, make sure that the appointments table contains the "name" column.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions