'Update values, or if no updates done, insert values
TODO: Make this return true/false on success/error
:param tableName: table to update/insert
:param valueDict: values in table to update/insert
:param keyDict:  columns in table to update/insert'

def upsert(self, tableName, valueDict, keyDict):

    changesBefore = self.connection.total_changes
    def genParams(my_dict):
        return [(x + u'    =    ?') for x in my_dict.keys()]
    query = (((((u'UPDATE    [' + tableName) + u']    SET    ') + u',    '.join(genParams(valueDict))) + u'    WHERE    ') + u'    AND    '.join(genParams(keyDict)))
    self.action(query, (list(valueDict.values()) + keyDict.values()))
    if (self.connection.total_changes == changesBefore):
        query = (((((((u'INSERT    INTO    [' + tableName) + u']    (') + u',    '.join((list(valueDict.keys()) + keyDict.keys()))) + u')') + u'    VALUES    (') + u',    '.join(([u'?'] * len((list(valueDict.keys()) + keyDict.keys()))))) + u')')
        self.action(query, (list(valueDict.values()) + keyDict.values()))
