'Save object into DB.'

def save(self):

    resp = self.response
    code = (int(resp.get_code()) / 100)
    values = [resp.get_id(), self.request.get_uri().url_string, resp.get_code(), self.tag, int(self.mark), str(resp.info()), resp.get_wait_time(), resp.get_msg(), resp.content_type, resp.charset, self.request.get_method(), len(resp.body), code, resp.get_alias(), int(self.request.get_uri().has_query_string())]
    if (not self.id):
        sql = ('INSERT    INTO    %s    (id,    url,    code,    tag,    mark,    info,    time,    msg,    content_type,    charset,    method,    response_size,    codef,    alias,    has_qs)    VALUES    (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)' % self._DATA_TABLE)
        self._db.execute(sql, values)
        self.id = self.response.get_id()
    else:
        values.append(self.id)
        sql = ('UPDATE    %s    SET    id    =    ?,    url    =    ?,    code    =    ?,    tag    =    ?,    mark    =    ?,    info    =    ?,    time    =    ?,    msg    =    ?,    content_type    =    ?,    charset    =    ?,    method    =    ?,    response_size    =    ?,    codef    =    ?,    alias    =    ?,    has_qs    =    ?    WHERE    id    =    ?' % self._DATA_TABLE)
        self._db.execute(sql, values)
    path_fname = self._get_fname_for_id(self.id)
    try:
        req_res = open(path_fname, 'wb')
    except IOError:
        (path, fname) = os.path.split(path_fname)
        split_path = path.split('/')
        for i in xrange((len(split_path) + 1)):
            test_path = '/'.join(split_path[:i])
            if (not os.path.exists(test_path)):
                msg = 'Directory    does    not    exist:    "%s"    while    trying    to    write    DB    history    to    "%s"'
                raise IOError((msg % (test_path, path_fname)))
        raise
    data = (self.request.to_dict(), self.response.to_dict(), self._MSGPACK_CANARY)
    msgpack.dump(data, req_res)
    req_res.close()
    return True
