python - 使用python在表格视图中显示来自不同表格的特定数据
问题描述
我想在表模型中完全显示 SQL 代码中的选定数据
def display_user_table(self):
header = ['Pupil Id','First Name','Last Name','Year Level','Plate Number', 'Car Brand', 'Car Colour' ]
data = show_pupil_table()
self.table_model = MyTableModel(self, data, header)
self.tableView.setModel(self.table_model)
self.tableView.resizeColumnsToContents()
self.tableView.resizeRowsToContents()
self.tableView.horizontalHeader().setStretchLastSection(True)
下面是我在表格模型中显示数据的代码
def show_pupil_table():
with ConnectionPool() as cursor:
cursor.execute('''SELECT pupil_first_name, pupil_last_name, year_level,plate_number, car_brand,car_colour
FROM pupil_info
JOIN family_pupil fp on pupil_info.pupil_id = fp.pupil_id
JOIN family_car fc on fp.family_id = fc.family_id
JOIN car_info ci on fc.car_id = ci.car_id;''')
return cursor.fetchall()
但它只显示了这一点
我理想的输出是这样
解决方案
推荐阅读
- php - 在 null 上调用成员函数 rating() - laravel
- php - 与规范键组合后如何对数组进行排序是php中的名称和值的字母顺序
- java - Spring:数组属性的默认值
- google-chrome - 无法清除浏览器缓存
- java - 在休眠条件中使用 sum
- opencv - 如何使用 protobuf 序列化 cv::Mat 对象?
- java - 从 SSRS 调用 url 时在 java web 上进行身份验证
- html - 如果存在 div,则两个 HTML 表格的对齐问题
- r - 如何使用字符串向量在 R 中使用 dplyr mutate 进行字符串匹配
- grapesjs - 使用 GrapesJs API 存储管理器的自定义 StorageManager