The code below inserts whatever data is typed into the text fields: name1 and phone1 into my database and I need to be able to type in stored data and retrieve it
def insert():
name1 = textin.get()
phone1 = textinn.get()
conn = sqlite3.connect('D:\lastfm-dataset-360K\msd.sqlite3')
with conn:
cursor = conn.cursor()
cursor.execute('INSERT INTO people(name, phone) VALUES(?,?)',(name1, phone1,))
db.close()
but=Button(root,padx=2,pady=2,text='Submit',command=insert,font=('none 13 bold'))
but.place(x=60,y=100)
I need to retrieve the records by typing them into the same text field and then print them out. So far I have this but Im confused with the SQL.
def show():
name1 = textin.get()
phone1 = textinn.get()
conn = sqlite3.connect('D:\lastfm-dataset-360K\msd.sqlite3')
with conn:
cursor = conn.cursor()
cursor.execute('SELECT * FROM people(name, phone) VALUES(?,?)',(name1, phone1,))
for row in cursor.fetchall():
print(row)
res=Button(root,padx=2,pady=2,text='Show',command=show,font=('none 13 bold'))
res.place(x=160,y=100)