singer_sdk.SQLTap

class singer_sdk.SQLTap[source]

Bases: Tap

A specialized Tap for extracting from SQL streams.

__init__(*args, **kwargs)[source]

Initialize the SQL tap.

The SQLTap initializer additionally creates a cache variable for _catalog_dict.

Parameters:
  • *args (Any) – Positional arguments for the Tap initializer.

  • **kwargs (Any) – Keyword arguments for the Tap initializer.

Return type:

None

classmethod append_builtin_config(config_jsonschema)[source]

Appends built-in config to config_jsonschema if not already set.

To customize or disable this behavior, developers may either override this class method or override the capabilities property to disabled any unwanted built-in capabilities.

For all except very advanced use cases, we recommend leaving these implementations “as-is”, since this provides the most choice to users and is the most “future proof” in terms of taking advantage of built-in capabilities which may be added in the future.

Parameters:

config_jsonschema (dict) – [description]

Return type:

None

classmethod cb_discover(ctx, param, value)[source]

CLI callback to run the tap in discovery mode.

Parameters:
  • ctx (Context) – Click context.

  • param (Option) – Click option.

  • value (bool) – Whether to run in discovery mode.

Return type:

None

classmethod cb_test(ctx, param, value)[source]

CLI callback to run the tap in test mode.

Parameters:
  • ctx (Context) – Click context.

  • param (Option) – Click option.

  • value (bool) – Whether to run in test mode.

Return type:

None

classmethod cb_version(ctx, param, value)[source]

CLI callback to print the plugin version and exit.

Parameters:
  • ctx (Context) – Click context.

  • param (Option) – Click parameter.

  • value (bool) – Boolean indicating whether to print the version.

Return type:

None

static config_from_cli_args(*args)[source]

Parse CLI arguments into a config dictionary.

Parameters:

args (str) – CLI arguments.

Raises:

FileNotFoundError – If the config file does not exist.

Returns:

A tuple containing the config dictionary and a boolean indicating whether the config file was found.

Return type:

tuple[list[Path], bool]

discover_streams()[source]

Initialize all available streams and return them as a sequence.

Returns:

A sequence of discovered Stream objects.

Return type:

t.Sequence[Stream]

format_message(message)[source]

Format a message as a JSON string.

Parameters:

message (M) – The message to format.

Returns:

The formatted message.

Return type:

T

classmethod get_plugin_version()[source]

Return the package version number.

Returns:

The package version number.

Return type:

str

classmethod get_sdk_version()[source]

Return the package version number.

Returns:

The package version number.

Return type:

str

classmethod get_singer_command()[source]

Execute standard CLI handler for taps.

Returns:

A click.Command object.

Return type:

Command

classmethod get_supported_python_versions()[source]

Return the supported Python versions.

Returns:

A list of supported Python versions.

Return type:

list[str] | None

classmethod invoke(*, about=False, about_format=None, config=(), state=None, catalog=None)[source]

Invoke the tap’s command line interface.

Parameters:
  • about (bool) – Display package metadata and settings.

  • about_format (str | None) – Specify output style for –about.

  • config (tuple[str, ...]) – Configuration file location or ‘ENV’ to use environment variables. Accepts multiple inputs as a tuple.

  • catalog (str | None) – Use a Singer catalog file with the tap.”,

  • state (str | None) – Use a bookmarks file for incremental replication.

Return type:

None

load_state(state)[source]

Merge or initialize stream state with the provided state dictionary input.

Override this method to perform validation and backwards-compatibility patches on self.state. If overriding, we recommend first running super().load_state(state) to ensure compatibility with the SDK.

Parameters:

state (dict[str, Any]) – Initialize the tap’s state with this value.

Raises:

ValueError – If the tap’s own state is None, meaning it has not been initialized.

Return type:

None

load_streams()[source]

Load streams from discovery and initialize DAG.

Return the output of self.discover_streams() to enumerate discovered streams.

Returns:

A list of discovered streams, ordered by name.

Return type:

list[Stream]

classmethod print_about(output_format=None)[source]

Print capabilities and other tap metadata.

Parameters:

output_format (str | None) – Render option for the plugin information.

Return type:

None

classmethod print_version(print_fn=<built-in function print>)[source]

Print help text for the tap.

Parameters:

print_fn (Callable[[Any], None]) – A function to use to display the plugin version. Defaults to print().

Return type:

None

run_connection_test()[source]

Run connection test, aborting each stream after 1 record.

Returns:

True if the test succeeded.

Return type:

bool

run_discovery()[source]

Write the catalog json to STDOUT and return as a string.

Returns:

The catalog as a string of JSON.

Return type:

str

run_sync_dry_run(dry_run_record_limit=1, streams=None)[source]

Run connection test.

Exceptions of type MaxRecordsLimitException and PartialSyncSuccessException will be ignored.

Parameters:
  • dry_run_record_limit (int | None) – The max number of records to sync per stream object.

  • streams (t.Iterable[Stream] | None) – The streams to test. If omitted, all streams will be tested.

Returns:

True if the test succeeded.

Return type:

bool

serialize_message(message)[source]

Serialize a dictionary into a line of json.

Parameters:

message (Message) – A Singer message object.

Returns:

A string of serialized json.

Return type:

str

setup_mapper()[source]

Initialize the plugin mapper for this tap.

Return type:

None

sync_all()[source]

Sync all streams.

Return type:

None

write_message(message)[source]

Write a message to stdout.

Parameters:

message (Message) – The message to write.

Return type:

None

write_schemas()[source]

Write a SCHEMA message for all known streams to STDOUT.

Return type:

None

property catalog: Catalog[source]

Get the tap’s working catalog.

Returns:

A Singer catalog object.

property catalog_dict: dict[source]

Get catalog dictionary.

Returns:

The tap’s catalog as a dict

property catalog_json_text: str[source]

Get catalog JSON.

Returns:

The tap’s catalog as formatted JSON text.

property config: Mapping[str, Any][source]

Get config.

Returns:

A frozen (read-only) config dictionary map.

default_stream_class: type[SQLStream][source]

The default stream class used to initialize new SQL streams from their catalog entries.

dynamic_catalog: bool = True[source]

Whether the tap’s catalog is dynamic, enabling configuration validation in discovery mode. Set to True if the catalog is generated dynamically (e.g. by querying a database’s system tables).

property initialized_at: int[source]

Start time of the plugin.

Returns:

The start time of the plugin.

property input_catalog: Catalog | None[source]

Get the catalog passed to the tap.

Returns:

Catalog dictionary input, or None if not provided.

property mapper: PluginMapper[source]

Plugin mapper for this tap.

Returns:

A PluginMapper object.

Raises:

MapperNotInitialized – If the mapper has not been initialized.

name: str[source]

The executable name of the tap or target plugin. e.g. tap-foo

package_name: str | None = None[source]

The package name of the plugin. e.g meltanolabs-tap-foo

property state: dict[source]

Get tap state.

Returns:

The tap’s state dictionary

Raises:

RuntimeError – If state has not been initialized.

property streams: dict[str, Stream][source]

Get streams discovered or catalogued for this tap.

Results will be cached after first execution.

Returns:

A mapping of names to streams, using discovery or a provided catalog.

property tap_connector: SQLConnector[source]

The connector object.

Returns:

The connector object.