Python Forum
[Tkinter] GUI taking data from oracle tables
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] GUI taking data from oracle tables
#1
i have a python code that creates a gui.
The first textbox entry requires from the user to enter a number (which is related to a column table data in db titled 'afm'). The table is 'customers'. I make the query using a cursor (=curs). According to this number the oracle table returns a result (ie 1111111). After that, I want a second query from another table (customer_desc): ‘select project_name from customer_desc where customer_name_d= the value in the customer box(=1111111)->company_name.set(result[1]) in python code below.
Any ideas? I need to make a new connection to the base? How can I set the where clause in order to read the textvalue returned to gui text field, with blind variables? Can you provided me with an example?
Thanks in advance.
 import cx_Oracle
   from tkinter import*
   from tkinter import messagebox

   def search():
   try:

    connstr='SOLVATIO/SOLVATIO@localhost'
    conn = cx_Oracle.connect(connstr)
    curs = conn.cursor()
    curs.execute("select * from customers where afm='%s'"%afm.get())
    result=curs.fetchone()
    company_name.set(result[1])
    e1.configure(state='disabled')
    conn.close()

    def clear():
   afm.set('')
   company_name.set('')
   e1.configure(state='normal')

   a1=Tk()
   a1.title('SOLVATIO')
   a1.geometry('600x300')
   ptitle=Label(a1, text='''search asset''')
   ptitle.grid(row=0, column=0, columnspan=2)

   afm=StringVar()
   company_name=StringVar()
   l1=Label (a1, text=' AFM ')
   e1=Entry(a1, textvariable=afm)
   l2=Label (a1, text=' customer ')
   e2=Entry(a1, textvariable=company_name)
   b1=Button(a1, text=' Search ', command=search)
   l1.grid(row=1, column=0)
   e1.grid(row=1, column=1)
   l2.grid(row=2, column=0)
   e2.grid(row=2, column=1)
   b1.grid(row=1, column=2)
   a1.mainloop()
Reply


Forum Jump:

User Panel Messages

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