我想用 python 制作 gui 以在 RDS MySQL DB 中显示 table

I want to make gui with python to display table in RDS MySQL DB

我想用 python 制作 gui 以在 RDS MySQL 数据库中显示 table 但我有 那个错误

 File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
return self.func(*args)
 File "GUI.py", line 30, in query
 records = c.fetchall()
 File "/usr/local/lib/python2.7/dist-packages/mysql/connector/cursor_cext.py", line 488, in fetchall
  raise errors.InterfaceError("No result set to fetch from.")
  InterfaceError: No result set to fetch from.

代码

try:
    # for Python2
    from Tkinter import *
except ImportError:
    # for Python3
    from tkinter import *
from PIL import ImageTk,Image
import sqlite3
import mysql.connector


root = Tk()
root.title('welcome reham')
#root.iconbitmap('@/home/A/x/GUI.xbm')
root.geometry("400x400")

#create query botton to show records in DB
def query():
    connection = mysql.connector.connect(host="*****",
                                 user="admin",
                                 passwd="******",
                                 database="attendance1")
    c = connection.cursor()
    c.execute = ("SELECT *, oid FROM empolyee")
    records = c.fetchall()
    print(records)

    print_records = ''
    for record in records:
    print_records += str(records) + "/n"
    query_labal = labal(root, text=print_records)
    query_labal.grid(row=2, column=0, columnspan=2, pady=10, padx=10, ipadx=137)
connection.commit()
connection.close()

#create query buttom
query_btn = Button(root, text="show records", command=query)
query_btn.grid(row=1, column=0, columnspan=2, pady=10, padx=10, ipadx=137)

root.mainloop() 

要执行查询,它必须是

c.execute("SELECT *, oid FROM empolyee") 

没有=


使用 = 您创建了变量 c.execute 而不是执行查询,因此稍后 fetchall() 无法获得结果 - 因为查询未执行 - 它显示 No result set to fetch from.