Skip to main content
Version: 1.15.0

SqliteDatasource

Signature

class great_expectations.datasource.fluent.SqliteDatasource(
*,
type: Literal['sqlite'] = 'sqlite',
name: str,
id: Optional[uuid.UUID] = None,
assets: List[Union[great_expectations.datasource.fluent.sql_datasource.TableAsset,
great_expectations.datasource.fluent.sql_datasource.QueryAsset]] = [],
connection_string: Union[great_expectations.datasource.fluent.config_str.ConfigStr,
great_expectations.datasource.fluent.sqlite_datasource.SqliteDsn],
create_temp_table: bool = False,
kwargs: Dict[str,
Union[great_expectations.datasource.fluent.config_str.ConfigStr,
Any]] = {}
)

Adds a sqlite datasource to the data context.

Parameters

NameDescription

name

The name of this sqlite datasource.

connection_string

The SQLAlchemy connection string used to connect to the sqlite database. For example: "sqlite:///path/to/file.db"

create_temp_table

Whether to leverage temporary tables during metric computation.

assets

An optional dictionary whose keys are TableAsset names and whose values are TableAsset objects.

Methods

add_query_asset

Signature

add_query_asset(
name: str,
query: str,
batch_metadata: Optional[BatchMetadata] = None
) → SqliteQueryAsset

Adds a query asset to this datasource.

Parameters

NameDescription

name

The name of this query asset.

query

The SELECT query to selects the data to validate. It must begin with the "SELECT".

batch_metadata

BatchMetadata we want to associate with this DataAsset and all batches derived from it.

Returns

TypeDescription

SqliteQueryAsset

The query asset that is added to the datasource. The type of this object will match the necessary type for this datasource. eg, it could be a QueryAsset or a SqliteQueryAsset.

add_table_asset

Signature

add_table_asset(
name: str,
table_name: str = '',
schema_name: str | Missing | None = <great_expectations.datasource.fluent.sql_datasource.Missing object>,
batch_metadata: Optional[BatchMetadata] = None
) → SqliteTableAsset

Adds a table asset to this datasource.

Parameters
  • name – The name of this table asset.

  • table_name – The table where the data resides.

  • schema_name

    The schema that holds the table. Will use the datasource schema if not provided.

    Deprecated since version 1.14.0: Pass the schema in your datasource's connection configuration instead.

  • batch_metadata – BatchMetadata we want to associate with this DataAsset and all batches derived from it.

Returns

TypeDescription

SqliteTableAsset

The table asset that is added to the datasource. The type of this object will match the necessary type for this datasource. eg, it could be a TableAsset or a SqliteTableAsset.

delete_asset

Signature

delete_asset(
name: str
)None

Removes the DataAsset referred to by asset_name from internal list of available DataAsset objects.

Parameters

NameDescription

name

name of DataAsset to be deleted.

get_asset

Signature

get_asset(
name: str
) → great_expectations.datasource.fluent.interfaces._DataAssetT

Returns the DataAsset referred to by asset_name

Parameters

NameDescription

name

name of DataAsset sought.

Returns

TypeDescription

great_expectations.datasource.fluent.interfaces._DataAssetT

if named "DataAsset" object exists; otherwise, exception is raised.