Good day. There was a problem with the search and output of the desired string from the database, I ask for help. There is a listbox in which the column values ​​are written. When you click on the value in the sheet box itself, this value is written to m. It is necessary to do so that when you click on the value in the listbox, a search is performed on the table and the entire row is displayed. (when I clicked on the last name, Ivanov would derive data on Ivanov from other columns: login, password, etc.) I did not find specific examples ((but I feel that you can somehow solve it via SELECT

conn = _sqlite3.connect('bd1') cur = conn.cursor() okno11 = Tk() okno11.title('текст титула') okno11.geometry('800x600') okno11.resizable(False, False) cur.execute("SELECT * FROM PUT") def select_item(event): value = (tx.get(tx.curselection())) m = value[:-1] print(m) textl = Label(okno11, text="пользователи:", font='Calibri') textl.grid(row=0, column=0, sticky='s') scrollbar = Scrollbar(okno11) tx = Listbox(okno11, font=('Calibri', 12), width=20, height=15, selectmode=SINGLE, yscrollcommand=scrollbar.set, selectforeground='red') scrollbar.grid(row=1, column=1, sticky='sn') scrollbar.config(command=tx.yview) tx.grid(row=1, column=0) tx.bind('<<ListboxSelect>>', select_item) while True: memory = cur.fetchone() if memory == None: break tx.insert(END, memory[1] + "\n") okno11.mainloop() 
  • if you do this: cur.execute ("SELECT * FROM PUT WHERE FIO IN ('Ivanov I.I.') p = cur.fetchall () print (p) then returns the string correctly, but I need to instead of Ivanov I.I. there was no variable m. ( - TheLast

1 answer 1

As it turned out the answer is close:

  cur.execute("SELECT * FROM PUT WHERE fio like '"+ m + "%'")