Skip to main content
Version: 1.2.0

MariaDBDestination

class MariaDBDestination(
uri: str,
destination_table: List[str] | str,
credentials: dict | UserPasswordCredentials = None,
if_table_exists: Literal['append', 'replace'] = 'append',
)

Bases: DestinationPlugin

Categories: destination

Class for managing the configuration of MariaDB-based data outputs.

Attributes: credentials (UserPasswordCredentials): The credentials required to access the MariaDB database. destination_table (str | List[str]): The table(s) to create. If multiple tables are provided, they must be provided as a list. if_table_exists ({'append', 'replace'}): The strategy to follow when the table already exists.

  • ‘replace’ will create a new database table, overwriting an existing one.
  • ‘append’ will append to an existing table. uri (str): The URI of the database where the data is going to be stored.

Initializes the MariaDBDestination with the given URI and destination table, and optionally connection credentials.

Parameters

parameter
uristr

The URI of the database where the data is going to be stored.

parameter
destination_tableList[str] | str

The tables to create. If multiple tables are provided, they must be provided as a list.

parameter
credentialsdict | UserPasswordCredentials, optional

The credentials required to access the MariaDB database. Can be a dictionary or a UserPasswordCredentials object.

parameter
if_table_exists\{'append', 'replace'\}, optional

The strategy to follow when the table already exists. Defaults to 'append'. - ‘replace’ will create a new database table, overwriting an existing one. - ‘append’ will append to an existing table.

Raises

OutputConfigurationError

Properties

property
credentialsUserPasswordCredentials

The credentials required to access the MariaDB database.

property
destination_tablestr | List[str]

The table(s) to create. If multiple tables are provided, they must be provided as a list.

property
if_table_existsLiteral['append', 'replace']

str: The strategy to follow when the table already exists.

property
uristr

The URI of the database where the data is going to be stored.

Methods

chunk
def chunk(working_dir: str, *results: LazyFrame | None) -> list[str | None]

Store the results in the SQL destination.

Parameters:

parameter
working_dirstr

The working directory where the results will be stored.

parameter
resultslist[pl.LazyFrame | None]

The results to store in the SQL destination.

write
def write(files: list[str | None])

Given a file or a list of files, write to the desired destination. Note: this method might materialize the data in the files it receives, so chunks should be of an appropriate size.

Parameters:

parameter
filesstr

The file or files to be stored in the final destination.