Skip to main content
GuideServerConfigure and deploy Tabsdata servers on your machine.TutorialsConfigure data integration workflows within a running Tabsdata server.API ReferenceCLI ReferenceRelease Notes
Version: 2.1.0

Subscribers

A subscriber function reads data from tables in the Tabsdata server and writes the data to an external system.

Subscribers in Action​

Tabsdata server
collection · warehouse
Table
vendors
//sales
Committed
Table
items
//sales
Committed
Connection
conn-mysql-dest.yaml
Subscriber
write_sales
Database
MySQL
MySQL · external
Not yet synced

Subscriber Code Anatomy​

sales-sub.py
1from tabsdatak.api import subscriber, TableFrameSpec
2import tabsdatak.api.tableframe as tdf
3from tabsdatak.conn.mysql import MySQLDest
4
5
1@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 vendors and items from the sales Collection.

  • Receives the input data and returns the data to write to MySQL.

    • The vendors and items arguments receive the data from input_tables in 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. Returning None for 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.

For inserts, updates, and deletes into Snowflake, BigQuery, or Databricks, see Merging into SQL destinations.