如何使用Python在TreeView中显示SQLite中的数据

时间:2019-02-19 11:39:30

标签: python sqlite

我有这个类,但是当我运行此应用程序时什么也没给我显示。.我的表中有7列,表头显示在我的应用程序上,只是sqlite的数据不显示。解决这个问题?

class Students:
db_name = 'Lutai.db'

def run_query(self, query, parameters = ()):
    with sqlite3.connect (self.db_name) as conn:
        cursor = conn.cursor()
        query_result = cursor.execute(query,parameters)
        conn.commit()
    return query_result

def viewing_records(self):
    records = self.tree.get_children()
    for element in records:
        self.tree.delete(element)
    query = "SELECT * FROM student ORDER BY nume DESC"
    db_rows = self.run_query(query)
    for row in db_rows:
        self.tree.insert('', 0, text=row[1], values=row[2])

我的课在这里也包含标签等照片: click here image from imgur.com

0 个答案:

没有答案