def accession_entry_map(klass):
    """Creates a `dict` mapping from accessions to the owning instance.
    for all instances in the database represented by `klass`.

    Parameters
    ----------
    klass : :class:`Pubmed` or :class:`Psimi`
        A class having the accession attribute.

    Returns
    -------
    dict[str, object]
        A dictionary mapping from accession to the associated instance.
    """
    if not hasattr(klass, 'accession'):
        raise AttributeError(
            "`{}` does not have the attribute `accession`." % klass.__name__
        )
    items = klass.query.all()
    mapping = {e.accession: e for e in items}
    return mapping