dimanche 13 mars 2016

Selecting a variable in a python sql code

So I have this command here:

def QuerySubmit():
    db = sqlite3.connect('File')
    cursor = db.cursor()
    sql1 = "select * FROM ProductTable"
    cursor.execute(sql1)
    result = cursor.fetchall()
    count = (len(result))
    for each in result:
        out = each
        message = out
        text2.insert(0.0, message)
        text2.insert(0.0, '\n' )
    cursor.close()

The problem is that I have created a optionbox with different variables in. I want these variables to appear where the * is, just when I do, the program doesn't seem to work. The code here is what I use for the optionbox:

  f2menu = tk.OptionMenu(f2, variable,*getvariablesP).place(x=400, y=75) 

I want the variable chosen from the menu to appear when the submit subroutine is run. The logical thing for me to do would to run

sql1 = "select ",f2menu,"FROM ProductTable

but this doesn't seem to work. Any help is valued.

Aucun commentaire:

Enregistrer un commentaire