def connection_from_s_or_c(s_or_c):
    """Args:
        s_or_c (str): Either an SQLAlchemy ORM :class:`Session`, or a core
            :class:`Connection`.

    Returns:
        Connection: An SQLAlchemy Core connection. If you passed in a
            :class:`Session`, it's the Connection associated with that session.

    Get you a method that can do both. This is handy for writing methods
    that can accept both :class:`Session`s and core :class:`Connection`s.

    """
    try:
        s_or_c.engine
        return s_or_c
    except AttributeError:
        return s_or_c.connection()