Subscribers
A subscriber function reads data from tables in the Tabsdata server and writes the data to an external system.
Subscribers in Action
Subscriber Code Anatomy
sales-sub.py
1from tabsdatak.api import subscriber, TableFrameSpec2import tabsdatak.api.tableframe as tdf3from tabsdatak.conn.mysql import MySQLDest451@subscriber(2 destination=MySQLDest(8 tables=["vendors", "items"],9 if_table_exists="replace",10 ),3 input_tables=["sales/vendors", "sales/items"],12)45def write_sales(vendors: TableFrameSpec, items: TableFrameSpec):6 vendors = vendors.filter(tdf.col("active") == 1)7 return (vendors, items)
Declares the tables to read and where to write them.
Connector class that performs the write. Address and credentials come from the collection's connection.
Tables to ship out, as
collection/table, mapped positionally to function body arguments.
Plain Python over TableFrames. Usually short, since the connector does the writing.
One parameter per input table, in order.
Shapes the frames before they are written out.
One frame per destination table, in order.
Noneskips that write.
For step-by-step guides on building a subscriber for a specific external system, see Subscribers under How-to Guides.