I had issues with delivering tkinter entry to sqlite My goal is build user interface to collect data and delete, show, update, I will keep learning.
I think my problem in
def savedata ():
I changed what inside brackets
I tried change this also
c.execute('INSERT INTO data (fname, sname) VALUES (?,?)',
(firstname_entry, secondnamename_entry))
conn.commit()
.
thank for helping
.
import random
import tkinter as tk
from tkinter import *
from tkinter import messagebox
import sqlite3
def conacona():
conn = sqlite3.connect('student.db')
c = conn.cursor()
c.execute("CREATE TABLE IF NOT EXISTS stud (firstname TEXT, secondname TEXT)")
conn.commit()
conn.close()
#oooooooo
main_menu = tk.Tk()
firstname_label = Label(main_menu, text="First name")
firstname_label.pack()
secondname_label = Label(main_menu, text="Second name")
secondname_label.pack()
# First name get
firstname_entry = tk.StringVar()
firstname_entry_entry = Entry(main_menu, textvariable = fn_ent_ent)
firstname_entry_entry.pack()
# Second name get
secondname_entry = tk.StringVar()
secondname_entry_entry = Entry(main_menu, textvariable = sn_ent_ent)
secondname_entry_entry.pack()
def savedata ():
conn = sqlite3.connect('stud.db')
c = conn.cursor()
c.execute('INSERT INTO data (fname, sname) VALUES (?,?)', (firstname_entry, secondnamename_entry))
conn.commit()
print("OK")
u_ent_btn = Button(text="Enter",command=savedata())
u_ent_btn.pack()
main_menu.mainloop()
fn_ent_entandsn_ent_entdefined?