我的数据库未返回任何内容-Python

时间:2018-10-03 20:31:04

标签: python sqlite tkinter

这是我的Application类,在其中我在数据库中输入数字和文本。但是,当我从AssignProfile2类获取数据库时,它什么也不返回。好像它是空的,但不是。我已经检查了atx函数是否正在运行。它正在运行,但是我的select命令没有返回任何内容

class Application(tk.Tk):
    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)
        self.configure(background='#a1dbcd')
        tk.Tk.iconbitmap(self, default="images\icon.ico")
        tk.Tk.wm_title(self, "Task Hub")
        mainframe = tk.Frame(self)
        mainframe.pack(side='top', fill='both', expand='True')
        mainframe.grid_rowconfigure(0, weight=1)
        mainframe.grid_columnconfigure(0, weight=1)
        self.frames = {}
        self.shared_data = {"main":"nada"}
        for Page in (Menu, MatterPage, TeacherPage, AddTeacher, Credits, AssignProfile, AssignProfile2):
            frame = Page(mainframe, self)
            self.frames[Page] = frame
            frame.grid(row=0, column=0, sticky='snew')
        self.show_frames(Menu)

    def show_frames_op(self, cont, tree):
        frame = self.frames[cont]
        frame.event_generate("<<ShowFrame>>")
        sptext = tree.item(tree.selection())['values'][1]
        cursor.execute("INSERT INTO Ctc (Id, Text) VALUES (?, ?);", (1, sptext))#<--------- Here
        conn.commit
        frame.tkraise()

class AssignProfile2(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.grid(padx=10)
        self.controller = controller
        self.bind("<<ShowFrame>>", self.atx)
        label = tk.Label(self, text="OI teste")
        label.grid(row=0, column=0)

    def atx(self, event):
        y = 1
        cursor.execute("SELECT * FROM Ctc;")
        conn.commit
        for h in cursor.fetchall():
            print(h[1])

0 个答案:

没有答案