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
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)
Defines the input Tables and destination for the Subscriber.
Writes data to the external system. The Collection's Connection provides the address and credentials.
Tabsdata Tables to read. This Subscriber reads
vendorsanditemsfrom thesalesCollection.
Receives the input data and returns the data to write to MySQL.
The
vendorsanditemsarguments receive the data frominput_tablesin the order listed.Filters the vendors to include only active vendors.
The returned data is written to the destination Tables in the order listed in
tables. ReturningNonefor a Table skips the write.
For step-by-step guides on building a subscriber for a specific external system, see Subscribers under How-to Guides.