from typing import Dict


def extract_tables_from_base(base) -> Dict[str, type]:
    """Extract tables and sqlalchemy declarative base classes from a base.

    Parameters
    ----------
    base : DeclarativeBase
        base from which to extract the model classes

    Returns
    -------
    result : dict[str, type]
        dictionary from tablename to sqlalchemy model class
    """
    tables = {}
    registry = base._decl_class_registry
    for dbase in registry.data.values():
        try:
            tablename = dbase().__table__.name
        except AttributeError:
            continue  # ignore _ModuleMarker
        else:
            modelclass = dbase().__mapper__.class_
            tables[tablename] = modelclass

    return tables