Does someone have a code example on how they solve...
# singer-tap-development
n
Does someone have a code example on how they solved a similar issue? I would need to load data from a "list" endpoint first and then go through all the new entries and do a "single get" query on each of them as well, as some of the data is only accessible in the single object endpoint. Example: • Get all invoices: https://docs.bexio.com/#tag/Invoices/operation/v2ListInvoices (does not have the list of positions) • Get one invoice https://docs.bexio.com/#tag/Invoices/operation/v2ShowInvoice (does have the list of positions) So basically I would need to query all invoices first and then query each invoice individually after that.
v
n
I did not yet know about it, but it looks perfect! will try it!
v
It's šŸ”„ you'll like it
n
It's really awesome and I think I am super close to solving it! I have one issue which is, that with the following code I created an endless loop to always query the same invoice forever. Any ideas what I did wrong? Ideally I would be able to write into the same table, but I think this doesn't work, right?
Copy code
class InvoicesStream(bexioStream):
    """Invoices stream."""
    name = "kb_invoices"
    path = "2.0/kb_invoice"
    data_key = "kb_invoice"
    primary_keys = ["id"]
    replication_method = "INCREMENTAL"
    replication_key = "id"
    schema_filepath = SCHEMAS_DIR / "kb_invoice.json"
    def get_child_context(self, record: dict, context: Optional[dict]) -> dict:
        """Return a context dictionary for child streams."""
        return {
            "invoice_id": record["id"],
        }

class InvoiceStream(bexioStream):
    """Invoice stream."""
    name = "kb_invoice"
    path = "2.0/kb_invoice/{invoice_id}"
    data_key = "kb_invoice"
    primary_keys = ["id"]
    replication_method = "INCREMENTAL"
    replication_key = "id"
    schema_filepath = SCHEMAS_DIR / "kb_invoice.json"
    # EpicIssues streams should be invoked once per parent epic:
    parent_stream_type = InvoicesStream
    # Assume epics don't have `updated_at` incremented when issues are changed:
    ignore_parent_replication_keys = True
v
Haven't heard about an infinite loop and idk about the code exactly, yes they are different streams. I don't know where some of those class vars are coming from like
data_key
but 🤷
n
haha alright, will dig deeper and try to solve it šŸ˜„
What exactly is the data key for? maybe this is what's triggering the endless loop?
v
I don't normally debug / do code review for folks on here, but I'd start at looking at your class names (they are the same)
n
Ok, thanks. they are not exactly the same šŸ˜‰ One is Invoices the other Invoice. I am sure I will find a way to solve it šŸ™‚