async def generate_entities(self) -> AsyncGenerator[ChunkEntity, None]:
        """Generate entities for all tables in specified schemas."""
        try:
            await self._connect()
            schema = self.config.get("schema", "public")
            tables = await self._get_table_list(schema)

            # Start a transaction
            async with self.conn.transaction():
                for table in tables:
                    # Create entity class if not already created
                    if f"{schema}.{table}" not in self.entity_classes:
                        self.entity_classes[f"{schema}.{table}"] = await self._create_entity_class(
                            schema, table
                        )

                    entity_class = self.entity_classes[f"{schema}.{table}"]
                    BATCH_SIZE = 50
                    offset = 0

                    while True:
                        # Fetch records in batches using LIMIT and OFFSET
                        batch_query = (
                            f'SELECT * FROM "{schema}"."{table}" LIMIT {BATCH_SIZE} OFFSET {offset}'
                        )
                        records = await self.conn.fetch(batch_query)

                        # Break if no more records
                        if not records:
                            break

                        # Process the batch
                        async for entity in self._process_table_batch(
                            schema, table, entity_class, records
                        ):
                            yield entity

                        # Increment offset for next batch
                        offset += BATCH_SIZE

        finally:
            if self.conn:
                await self.conn.close()
                self.conn = None
Generate entities for all tables in specified schemas.
backend/airweave/platform/sources/postgresql.py