python - 如何使用 python 在树视图中显示来自 sqlite 的数据
问题描述
我有这个类,但是当我运行这个应用程序时没有显示任何东西..我的表格中有七列,表格的标题出现在我的应用程序上,只是来自 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])
我的班级还包含标签等照片:
解决方案
推荐阅读
- python - 我得到 ValueError: 'Dip Time' 不在列表中
- android - WorkManager 和 Kodein
- microservices - 身份验证策略的 Istio 替代方案是什么,开发的 Istio 流程是什么?
- linkedin - LinkedIn - 无法创建访问令牌,回复“此应用程序不允许创建应用程序令牌”。#linkedin
- php - 邮件函数返回真但没有收到电子邮件
- c# - 构建 IQueryable
然后将其附加到 DbSet - python - 为什么在 odoo 10 中会出现此错误“重置模块状态”
- xcode - 无法从项目目录打开 Runner.xwworkspace 文件
- javascript - 调整 Android 浏览器输入日期的默认 UI
- javascript - 即使在 React 中使用 .exit().remove(),D3 也会继续重新渲染