singer_sdk.SQLTarget#
- class singer_sdk.SQLTarget#
Bases:
Target
Target implementation for SQL destinations.
- __init__(*, config: dict | PurePath | str | list[PurePath | str] | None = None, parse_env_config: bool = False, validate_config: bool = True, setup_mapper: bool = True) None #
Initialize the target.
- Parameters:
config – Target configuration. Can be a dictionary, a single path to a configuration file, or a list of paths to multiple configuration files.
parse_env_config – Whether to look for configuration values in environment variables.
validate_config – True to require validation of config settings.
setup_mapper – True to setup the mapper. Set to False if you want to
- add_sink(stream_name: str, schema: dict, key_properties: t.Sequence[str] | None = None) Sink #
Create a sink and register it.
This method is internal to the SDK and should not need to be overridden.
- Parameters:
stream_name – Name of the stream.
schema – Schema of the stream.
key_properties – Primary key of the stream.
- Returns:
A new sink for the stream.
- Raises:
Exception – If sink setup fails.
- final add_sqlsink(stream_name: str, schema: dict, key_properties: t.Sequence[str] | None = None) Sink #
Create a sink and register it.
This method is internal to the SDK and should not need to be overridden.
- Parameters:
stream_name – Name of the stream.
schema – Schema of the stream.
key_properties – Primary key of the stream.
- Returns:
A new sink for the stream.
- classmethod append_builtin_config(config_jsonschema: dict) None #
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 – [description]
- classmethod cb_version(ctx: Context, param: Option, value: bool) None #
CLI callback to print the plugin version and exit.
- Parameters:
ctx – Click context.
param – Click parameter.
value – Boolean indicating whether to print the version.
- static config_from_cli_args(*args: str) tuple[list[Path], bool] #
Parse CLI arguments into a config dictionary.
- Parameters:
args – 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.
- deserialize_json(line: str) dict #
Deserialize a line of json.
- Parameters:
line – A single line of json.
- Returns:
A dictionary of the deserialized json.
- Raises:
json.decoder.JSONDecodeError – raised if any lines are not valid json
- drain_all(*, is_endofpipe: bool = False) None #
Drains all sinks, starting with those cleared due to changed schema.
This method is internal to the SDK and should not need to be overridden.
- Parameters:
is_endofpipe – This is passed by the
_process_endofpipe()
which is called after the target instance has finished listening to the stdin
- drain_one(sink: Sink) None #
Drain a specific sink.
This method is internal to the SDK and should not need to be overridden.
- Parameters:
sink – Sink to be drained.
- classmethod get_plugin_version() str #
Return the package version number.
- Returns:
The package version number.
- classmethod get_sdk_version() str #
Return the package version number.
- Returns:
The package version number.
- classmethod get_singer_command() Command #
Execute standard CLI handler for taps.
- Returns:
A click.Command object.
- get_sink(stream_name: str, *, record: dict | None = None, schema: dict | None = None, key_properties: t.Sequence[str] | None = None) Sink #
Return a sink for the given stream name.
A new sink will be created if schema is provided and if either schema or key_properties has changed. If so, the old sink becomes archived and held until the next drain_all() operation.
Developers only need to override this method if they want to provide a different sink depending on the values within the record object. Otherwise, please see default_sink_class property and/or the get_sink_class() method.
Raises
singer_sdk.exceptions.RecordsWithoutSchemaException
if sink does not exist and schema is not sent.- Parameters:
stream_name – Name of the stream.
record – Record being processed.
schema – Stream schema.
key_properties – Primary key of the stream.
- Returns:
The sink used for this target.
- get_sink_class(stream_name: str) type[SQLSink] #
Get sink for a stream.
Developers can override this method to return a custom Sink type depending on the value of stream_name. Optional when default_sink_class is set.
- Parameters:
stream_name – Name of the stream.
- Raises:
ValueError – If no
singer_sdk.sinks.Sink
class is defined.- Returns:
The sink class to be used with the stream.
- classmethod get_supported_python_versions() list[str] | None #
Return the supported Python versions.
- Returns:
A list of supported Python versions.
- classmethod invoke(*, about: bool = False, about_format: str | None = None, config: tuple[str, ...] = (), file_input: IO[str] | None = None) None #
Invoke the target.
- Parameters:
about – Display package metadata and settings.
about_format – Specify output style for –about.
config – Configuration file location or ‘ENV’ to use environment variables. Accepts multiple inputs as a tuple.
file_input – Optional file to read input from.
- listen(file_input: IO[str] | None = None) None #
Read from input until all messages are processed.
- Parameters:
file_input – Readable stream of messages. Defaults to standard in.
This method is internal to the SDK and should not need to be overridden.
- classmethod print_about(output_format: str | None = None) None #
Print capabilities and other tap metadata.
- Parameters:
output_format – Render option for the plugin information.
- classmethod print_version(print_fn: ~typing.Callable[[~typing.Any], None] = <built-in function print>) None #
Print help text for the tap.
- Parameters:
print_fn – A function to use to display the plugin version. Defaults to print.
- setup_mapper() None #
Initialize the plugin mapper for this tap.
- sink_exists(stream_name: str) bool #
Check sink for a stream.
This method is internal to the SDK and should not need to be overridden.
- Parameters:
stream_name – Name of the stream
- Returns:
True if a sink has been initialized.
- property config: Mapping[str, Any]#
Get config.
- Returns:
A frozen (read-only) config dictionary map.
- property initialized_at: int#
Start time of the plugin.
- Returns:
The start time of the plugin.
- property mapper: PluginMapper#
Plugin mapper for this tap.
- Returns:
A PluginMapper object.
- Raises:
MapperNotInitialized – If the mapper has not been initialized.
- property max_parallelism: int#
Get max parallel sinks.
The default is 8 if not overridden.
- Returns:
Max number of sinks that can be drained in parallel.
- name: str#
The executable name of the tap or target plugin. e.g. tap-foo
- package_name: str | None = None#
The package name of the plugin. e.g meltanolabs-tap-foo
- property state: dict#
Get state.
- Raises:
NotImplementedError – If the derived plugin doesn’t override this method.
- property target_connector: SQLConnector#
The connector object.
- Returns:
The connector object.