-1

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

  • Please [edit] your question and provide a valid [mre], and check its syntax (including indentation) before submitting again. – musicamante Jul 09 '23 at 17:12

1 Answers1

0

You problem is not about mariadb or fetching the data. You made something wrong with connection of a signal from your button to the slot on_refreshBtn_clicked(). You haven't provided this part of your code so it isn't possible to say what you did wrong there.

StarterKit
  • 488
  • 4
  • 15