def get_class_by_tablename(base, tablename): """Return class reference mapped to table. :param tablename: String with name of table. :return: Class reference or None. """ for _class in base._decl_class_registry.values(): if hasattr( _class, '__tablename__') and _class .__tablename__ == tablename: return _class return ValueError("Could not find table")
Leave a Reply