Python Forum
problem python search engine
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem python search engine
#1
hi,i need help, I want to create a python search engine that will search for clients' names (from a sqlite3 database and display them on the Treeview object),search automatically without clicking on search Button (i.e. in real time).
The code below allows a good search but the problem is that it doesn't take into account the last letter typed.
example
if I write in the search field 'Nam' it executes the search for 'Na' just
if I write in the search field 'Name' it performs the search for 'Nam' just (i.e. either press enter or a key so that it performs the search)
def SearchByName(event):
    for x in Tree.get_children():
        Tree.delete(x)
    Name = entrySearchByName.get()
    conn = sqlite3.connect('database.db')
    cur = conn.cursor()
    SQL = "SELECT*FROM customers where Name LIKE ?"
    Wc_Name = "%{}%".format(Name)
    select = cur.execute(SQL, (Wc_Name,))
    select =list(select)
    conn.commit()
    for row in select:
        Tree.insert('', END, values = row)
        conn.close()

lbSearchByName = Label(root, text="Search By Name :", font=("Times New Roman",18))
lbSearchByName.place(x=540, y=2)
entrySearchByName = Entry(root)
entrySearchByName.place(x=730, y=7, width=250, height=25)
entrySearchByName.bind("<Key>", SearchByName)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Djongo (mongoDb) - Django rest framework Problem with search on JsonFields grzybekrafal 0 2,463 May-11-2021, 09:04 AM
Last Post: grzybekrafal
  Search Engine nman52 1 53,461 Dec-16-2020, 11:46 AM
Last Post: Larz60+
  Understanding Python's Import Engine MysticaL 1 2,154 Feb-07-2020, 11:26 PM
Last Post: snippsat
  instaloaders problem: search certain hashtag - posts without hashtag extracted ledgreve 0 2,145 Nov-18-2019, 01:22 PM
Last Post: ledgreve
  Voynich search engine in python using dashes & dot totals to find Italian words Pleiades 3 3,484 Oct-10-2019, 10:04 PM
Last Post: Pleiades
  Making an application with a 3d engine in it moo5e 1 2,110 May-27-2019, 03:17 PM
Last Post: heiner55
  Python Trading Engine icabero0225 3 5,143 May-27-2017, 09:53 PM
Last Post: bigmit37

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020