'return a dictionary of bind parameter keys and values'

def construct_params(self, params=None, _group_number=None, _check=True):

    if params:
        pd = {}
        for (bindparam, name) in self.bind_names.items():
            if (bindparam.key in params):
                pd[name] = params[bindparam.key]
            elif (name in params):
                pd[name] = params[name]
            elif (_check and bindparam.required):
                if _group_number:
                    raise exc.InvalidRequestError(('A    value    is    required    for    bind    parameter    %r,    in    parameter    group    %d' % (bindparam.key, _group_number)))
                else:
                    raise exc.InvalidRequestError(('A    value    is    required    for    bind    parameter    %r' % bindparam.key))
            else:
                pd[name] = bindparam.effective_value
        return pd
    else:
        pd = {}
        for bindparam in self.bind_names:
            if (_check and bindparam.required):
                if _group_number:
                    raise exc.InvalidRequestError(('A    value    is    required    for    bind    parameter    %r,    in    parameter    group    %d' % (bindparam.key, _group_number)))
                else:
                    raise exc.InvalidRequestError(('A    value    is    required    for    bind    parameter    %r' % bindparam.key))
            pd[self.bind_names[bindparam]] = bindparam.effective_value
        return pd
