Building a desktop app using pyside6, trying to get the refresh button to fetch data from a mariadb and insert into a table widget
Class Connectionmaria(): def init(self): print("yes 9") self.host = "127.0.0.1" self.user = "root" self.password = "518Oloko." self.port = 3306 self.database = "Labpal" self.con = None def connect(self): self.con = mariadb.connect( host = self.host, user = self.user, password = self.password, port = self.port, database = self.database ) def get_data_from_store_db(self): try: self.connect() cursor = self.con.cursor(dictionary=True) sql = "SELECT * FROM store_log" cursor.execute(sql) result = cursor.fetchall() #print(result) return result except Exception as e: print("get data failed") finally: if self.con: self.con.close
def get_data_from_store_db(self): try: self.connect() cursor = self.con.cursor(dictionary=True) sql = "SELECT * FROM store_log" cursor.execute(sql) result = cursor.fetchall() #print(result) return result except Exception as e: print("get data failed") finally: if self.con: self.con.close
@Slot(bool) def on_refreshBtn_clicked(self): result = Connectionmaria().get_data_from_store_db() if result: self.storeTree.setRowCount(len(result)) for row, item in enumerate(result): column_1_item = QTableWidgetItem(str(item['column 1'])) self.storeTree.setItem(row, 0, column_1_item) else: QMessageBox.informaation(self, 'Warning', 'No data gotten from database') return
but i keep getting this error when i clicked the refresh button TypeError: MainWindow.on_refreshBtn_clicked() takes 1 positional argument but 2 were given