MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / setup_mappers

Method setup_mappers

test/ext/test_horizontal_shard.py:166–193  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

164
165 @classmethod
166 def setup_mappers(cls):
167 global WeatherLocation, Report
168
169 class WeatherLocation:
170 def __init__(self, continent, city):
171 self.continent = continent
172 self.city = city
173
174 class Report:
175 def __init__(self, temperature, id_=None):
176 self.temperature = temperature
177 if id_:
178 self.id = id_
179
180 weather_locations = cls.tables.weather_locations
181
182 cls.mapper_registry.map_imperatively(
183 WeatherLocation,
184 weather_locations,
185 properties={
186 "reports": relationship(Report, backref="location"),
187 "city": deferred(weather_locations.c.city),
188 },
189 )
190
191 weather_reports = cls.tables.weather_reports
192
193 cls.mapper_registry.map_imperatively(Report, weather_reports)
194
195 def _fixture_data(self):
196 tokyo = WeatherLocation("Asia", "Tokyo")

Callers

nothing calls this directly

Calls 3

relationshipFunction · 0.90
deferredFunction · 0.90
map_imperativelyMethod · 0.80

Tested by

no test coverage detected