Insert rows as represented by the fixtures() method.
(cls)
| 189 | |
| 190 | @classmethod |
| 191 | def _load_fixtures(cls): |
| 192 | """Insert rows as represented by the fixtures() method.""" |
| 193 | headers, rows = {}, {} |
| 194 | for table, data in cls.fixtures().items(): |
| 195 | if len(data) < 2: |
| 196 | continue |
| 197 | if isinstance(table, str): |
| 198 | table = cls.tables[table] |
| 199 | headers[table] = data[0] |
| 200 | rows[table] = data[1:] |
| 201 | for table, fks in sort_tables_and_constraints( |
| 202 | cls._tables_metadata.tables.values() |
| 203 | ): |
| 204 | if table is None: |
| 205 | continue |
| 206 | if table not in headers: |
| 207 | continue |
| 208 | with cls.bind.begin() as conn: |
| 209 | conn.execute( |
| 210 | table.insert(), |
| 211 | [ |
| 212 | dict(zip(headers[table], column_values)) |
| 213 | for column_values in rows[table] |
| 214 | ], |
| 215 | ) |
| 216 | |
| 217 | |
| 218 | class NoCache: |