Q:

SQLite and tableWidget

How to make Headers in the QTableWidget also updated after calling the loadData. 
def loadData(self):
    connection = sqlite3.connect('CUSP.db')
    query = "SELECT * FROM ZAYAVITEL"
    result = connection.execute(query)
    self.tableWidget.setColumnCount(6)
    for row_number, row_data in enumerate(result):
        self.tableWidget.insertRow(row_number)
        for column_number, data in enumerate(row_data):
            self.tableWidget.setItem(row_number, column_number, QtWidgets.QTableWidgetItem(str(data)))
    connection.close()

A:

You can get the name of the columns using the cursor.description:
def loadData(self):
    self.tableWidget.setColumnCount(0)
    self.tableWidget.setRowCount(0)

    connection = sqlite3.connect("CUSP.db")
    cursor = connection.execute("SELECT * FROM ZAYAVITEL")
    # https://stackoverflow.com/a/7831685/6622587
    names = [description[0] for description in cursor.description]
    self.tableWidget.setColumnCount(len(names))
    self.tableWidget.setHorizontalHeaderLabels(names)

    for i, row_data in enumerate(cursor):
        self.tableWidget.insertRow(i)
        for j, value in enumerate(row_data):
            it = QtWidgets.QTableWidgetItem()
            it.setData(QtCore.Qt.DisplayRole, value)
            self.tableWidget.setItem(i, j, it)

