When using the singer.write_records()
method we pass a stream id as a string and a record as dict, for example:
singer.write_records(
stream_name="example_stream",
records={"product1": "val1", "product2": "val2", "shop": "example_shop"}
)
But I have seen code where we pass a generator object to the records parameter instead of a dictionary, for example:
singer.write_records(
stream_name="products",
records=({**item, "shop": shop}
for item in retrieve_products(shop))
)
Why is this possible? Where does the singer spec explicitly define which arguments the write_records()
can take? How does the method process the data passed to the records field? I've looked up the singer specification but couldn't find any definition of write_records()
. I also tried running help(singer.write_records())
in the Python console, but the information printed wasn't helpful.