great_expectations.datasource.sqlalchemy_datasource

Module Contents

Classes

SqlAlchemyDatasource(name=’default’, data_context=None, data_asset_type=None, credentials=None, batch_kwargs_generators=None, **kwargs)

A SqlAlchemyDatasource will provide data_assets converting batch_kwargs using the following rules:

great_expectations.datasource.sqlalchemy_datasource.logger
great_expectations.datasource.sqlalchemy_datasource.sqlalchemy
great_expectations.datasource.sqlalchemy_datasource.datasource_initialization_exceptions
class great_expectations.datasource.sqlalchemy_datasource.SqlAlchemyDatasource(name='default', data_context=None, data_asset_type=None, credentials=None, batch_kwargs_generators=None, **kwargs)

Bases: great_expectations.datasource.Datasource

A SqlAlchemyDatasource will provide data_assets converting batch_kwargs using the following rules: - if the batch_kwargs include a table key, the datasource will provide a dataset object connected

to that table

  • if the batch_kwargs include a query key, the datasource will create a temporary table using that that query. The query can be parameterized according to the standard python Template engine, which uses $parameter, with additional kwargs passed to the get_batch method.

recognized_batch_parameters
classmethod build_configuration(cls, data_asset_type=None, batch_kwargs_generators=None, **kwargs)

Build a full configuration object for a datasource, potentially including generators with defaults.

Parameters
  • data_asset_type – A ClassConfig dictionary

  • batch_kwargs_generators – Generator configuration dictionary

  • **kwargs – Additional kwargs to be part of the datasource constructor’s initialization

Returns

A complete datasource configuration.

_get_sqlalchemy_connection_options(self, **kwargs)
get_batch(self, batch_kwargs, batch_parameters=None)

Get a batch of data from the datasource.

Parameters
  • batch_kwargs – the BatchKwargs to use to construct the batch

  • batch_parameters – optional parameters to store as the reference description of the batch. They should reflect parameters that would provide the passed BatchKwargs.

Returns

Batch

process_batch_parameters(self, query_parameters=None, limit=None, dataset_options=None)

Use datasource-specific configuration to translate any batch parameters into batch kwargs at the datasource level.

Parameters
  • limit (int) – a parameter all datasources must accept to allow limiting a batch to a smaller number of rows.

  • dataset_options (dict) – a set of kwargs that will be passed to the constructor of a dataset built using these batch_kwargs

Returns

Result will include both parameters passed via argument and configured parameters.

Return type

batch_kwargs