def insert_data(self, table, select_results=[], **new_row):
        """
        Insert a new row in the given table.
        Basically it's just a more generic version of add_host
        """
        results = []
        updated_ids = []

        # Create new row
        if not select_results:
            results = [new_row]
        # Update existing row data
        else:
            for row in select_results:
                row_data = row._asdict()
                for column,value in new_row.items():
                    row_data[column] = value

                # Only add data to be updated if it has changed
                if row_data not in results:
                    results.append(row_data)
                    updated_ids.append(row_data['id'])

        cme_logger.debug(f'Update data: {results}')
        # TODO: find a way to abstract this away to a single Upsert call
        q = Insert(table) # .returning(table.c.id)
        update_column = {col.name: col for col in q.excluded if col.name not in 'id'}
        q = q.on_conflict_do_update(index_elements=table.primary_key, set_=update_column)
        self.conn.execute(q, results) # .scalar()
        # we only return updated IDs for now - when RETURNING clause is allowed we can return inserted
        return updated_ids

        Insert a new row in the given table.
        Basically it's just a more generic version of add_host
        
cme/protocols/smb/database.py