title: sqlalchemy map entire table into attribute with classical mapping
body: <p>Given the following class and database tables</p>
  <pre class="lang-py prettyprint-override"><code>class Location:
      datacenter_name: str
      path: str
  
  locations = Table(
      &quot;locations&quot;,
      mapper_registry.metadata,
      Column(&quot;id&quot;, Integer, primary_key=True, autoincrement=True),
      Column(&quot;path&quot;, String, nullable=False),
      Column(&quot;datacenter_name&quot;, String, nullable=False),
  )
  mapper_registry.map_imperatively(Location, locations)
  
  backup_registry = Table(
      &quot;backup_registry&quot;,
      mapper_registry.metadata,
      Column(&quot;id&quot;, Integer, primary_key=True, autoincrement=True),
      Column(&quot;source_location_id&quot;, ForeignKey(&quot;locations.id&quot;), nullable=False),
      Column(&quot;backup_location_id&quot;, ForeignKey(&quot;locations.id&quot;), nullable=False),
  )
  </code></pre>
  <p>I want to map the <code>backup_registry</code> table to a BackupRegistry instance, but I need
  to map <strong>all rows into a single attribute</strong>, for example:</p>
  <pre class="lang-py prettyprint-override"><code>class BackupRegistry:
      backups: Dict[Location, list[Location]]
  </code></pre>
  <p>Using the same approach as with location would give me one BackupRegistry instance
  per row <code>mapper_registry.map_imperatively(BackupRegistry, backup_registry)</code></p>
  <p>Any thoughts on how this could be accomplished with classical mapping?</p>