Here is my label and entry box in Tkinter (only for customer's name, it looks similar for other inputs). My goal is to type some word in this entry box and then insert it into the database, by pressing button "Save".
conn = sqlite3.connect('my_database.db')
cur = conn.cursor()
CustomerName = StringVar()
lblName = Label(bottomLeftTopL, font = ('arial', 16, 'bold'), text = "Name", fg
= 'black', width = 15, bd = 10, anchor = 'w')
lblName.grid(row = 0, column = 0)
txtName = Entry(bottomLeftTopL, font = ('arial', 16, 'bold'), bd = 2, width =
24, bg = 'white', justify = 'left', textvariable = CustomerName)
txtName.grid(row = 0, column = 1)
My button which I want to use to save inputs into the database.
btnSave = Button(bottomLeftBottomL, pady = 8, bd = 2,
fg = 'black', font = ('arial', 10, 'bold'), width = 10, text = "Save",
bg = 'white').grid(row = 7, column = 1)
Here's my class for customer's table in SQLAlchemy.
class Customers(Base):
__tablename__ = "customers"
id_customer = Column(Integer, primary_key = True)
name = Column(String)
phone_number = Column(String)
adress = Column(String)
def __init__(self, name, phone_number, adress):
self.name = name
self.phone_number = phone_number
self.adress = adress
I guess I need to use the cursor and 'Insert into' statement. Could anybody help me to write the function for this operation?