MariaDB
The MariaDB connector lets Tabsdata run queries against MariaDB and write tables into MariaDB.
The MySQLSrc connector can be used by a publisher function to read data from MariaDB into a Tabsdata table.
The MySQLDest connector can be used by a subscriber function to write data from a Tabsdata table into MariaDB.
Publisher
The MySQLSrc connector can be used by a publisher function to read data from MariaDB into a Tabsdata table. See the full publisher walkthrough
Connection
MariaDB publishers use MySQLSrcConn to define the database connection and credentials used by the publisher.
kind: connectionDef
apiVersion: '1.0'
type: tabsdatak.conn.mysql:MySQLSrcConn
spec:
uri: 'mariadb://db.internal:3306/world'
credentials:
kind: userPasswordCredentials
apiVersion: '1.0'
type: tabsdatak.conn.common.types:UserPassword
spec:
user: 'secret:tabsdata_reader'
password: 'secret:example-password'
- required
- required
- optional
- optional
Connection Config Parameters
uri
The SQLAlchemy-style connection URI: mariadb://host:port/database. Written as a plain value here, but accepts secret: too.
credentials
The database user and password, spliced into the URI at connect time. UserPassword requires a user and password.
entity_whitelist
Limits which source tables are discovered (registered in the collection's table catalog) when the source collection is created: a YAML list of regular expressions, not a comma-separated string. A table is kept if it matches any pattern. Omit it entirely to discover every table in the database.
conn_cfg
Driver-side options forwarded to the connection as SQLAlchemy connect_args.
Publisher
Configure MySQLSrc as the source of a publisher function to select the queries that Tabsdata runs against MariaDB.
from tabsdatak.api import publisher
from tabsdatak.conn.mysql import MySQLSrc
@publisher(
source=MySQLSrc(
queries=[
"SELECT * FROM orders",
],
),
output_tables=["orders"],
)
def publish_orders(orders):
return orders
- required
- optional
- optional
Function Config Parameters
queries
Defines the SQL queries the publisher runs against MariaDB.
Each element in queries represents one source slot and maps positionally to an argument in the publisher function.
For example:
MySQLSrc(
queries=[
"SELECT * FROM country",
"SELECT * FROM city",
],
)
initial_values
Values substituted into {placeholder}-style tokens inside queries, so one publisher can read the same tables out of a different schema or catalog without the SQL changing.
src_cfg
Sets additional source configuration.
Subscriber
The MySQLDest connector can be used by a subscriber function to write data from a Tabsdata table into MariaDB. See the full subscriber walkthrough
Connection
MariaDB subscribers use MySQLDestConn to define the database connection and credentials used by the subscriber.
kind: connectionDef
apiVersion: '1.0'
type: tabsdatak.conn.mysql:MySQLDestConn
spec:
uri: 'mariadb://db.internal:3306/warehouse'
credentials:
kind: userPasswordCredentials
apiVersion: '1.0'
type: tabsdatak.conn.common.types:UserPassword
spec:
user: 'secret:tabsdata_reader'
password: 'secret:example-password'
- required
- required
- optional
- optional
Connection Config Parameters
uri
The SQLAlchemy-style connection URI: mariadb://host:port/database. Written as a plain value here, but accepts secret: too.
credentials
The database user and password, spliced into the URI at connect time. UserPassword requires a user and password.
entity_whitelist
Limits which destination tables are discovered (registered in the collection's table catalog) when the destination collection is created: a YAML list of regular expressions, not a comma-separated string. A table is kept if it matches any pattern. Omit it entirely to discover every table in the database.
conn_cfg
Driver-side options forwarded to the connection as SQLAlchemy connect_args.
Subscriber
Configure MySQLDest as the destination of a subscriber function to define which tables Tabsdata writes in MariaDB.
from tabsdatak.api import subscriber
from tabsdatak.conn.mysql import MySQLDest
@subscriber(
destination=MySQLDest(
tables=[
"orders",
],
),
input_tables=["orders"],
)
def write_orders(orders):
return orders
- required
- optional
- optional
Function Config Parameters
tables
Defines the destination tables the subscriber writes to in MariaDB.
Each element in tables represents one destination slot and maps positionally to a value returned by the subscriber function.
For example:
MySQLDest(
tables=[
"vendors",
"items",
],
)
if_table_exists
Controls what happens when the destination table already has rows. "append" (the default) keeps inserting into the existing rows. "replace" truncates the table before inserting. Neither mode changes the destination table's schema, so the returned frame's columns need to match the table MariaDB already has.
dest_cfg
Sets additional destination configuration.