Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Link text field to separate python file
Hi Guys,

I am trying to take the values of a text field in my file, and feed the values in to a search option in So when the user types in a username and presses a button, the username they have searched for is then transferred to the file to run searches against a database. I am really not too sure how to do this. I am using Tkinter.

This is my retrieve code:

def username():
    c = conn.cursor
    name = raw_input ("Enter Username")
    c.execute("SELECT users FROM Results WHERE users LIKE '%"+name+"%';")
    data = c.fetchall()
    print (data)
Do not post code as you did. I added code tags in the proper manner.

The gui code should use a get user button that is bound to the retrieve function
this can be done in the command argument of the button instance or with a separate
bind statement attached to the button. In either case, you will have to provide an event hook
as an argument in retrieve.
.close is a method.  You need parenthases to call it.  c.close() and conn.close().

And please, don't write sql queries like that.  Use the string formatting the db engine provides, so the values are escaped properly (otherwise a "well written" text snippet could "accidentally" delete your entire database).  So maybe
user = "%{}%".format(name)
c.execute("select users from results where users like ?", user)

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Kivy] Can't link .kw file with Allpha 2 1,423 Aug-14-2017, 08:05 PM
Last Post: metulburr

Forum Jump:

Users browsing this thread: 1 Guest(s)