# This Python file uses the following encoding: utf-8 import sys import os import sqlite3 from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot class DataBase(QAbstractTableModel): def __init__(self, con): super().__init__() self.con = con self.__data = self.__getData() def __getData(self): cursor = self.con.cursor() cursor.execute("SELECT * FROM test") return cursor.fetchall() def rowCount(self, parent= QModelIndex()): return len (self.__data) def columnCount(self, parent= QModelIndex()): return 3 def data(self, index, role= Qt.DisplayRole): if role == Qt.DisplayRole: row, col = index.row(), index.column() return self.__data[row][col] return None def headerData(self, section, orientation, role= Qt.DisplayRole): header= ["ID", "Kundenname", "Ort"] if orientation == Qt.Horizontal and role ==Qt.DisplayRole: return header[section] return super().headerData(section, orientation, role) #return None @Slot(int) def onRowClicked(self, row): print(row)