TapLoadingVisitor

class felis.tap.TapLoadingVisitor(engine, catalog_name=None, schema_name=None, tap_tables=None, tap_schema_index=None)

Bases: object

Generate TAP_SCHEMA data and insert it into a database using the SQLAlchemy ORM.

Parameters:
  • engine (Engine | None) – SQLAlchemy engine instance.

  • catalog_name (str | None, default: None) – Name of the database catalog.

  • schema_name (str | None, default: None) – Name of the schema.

  • tap_tables (MutableMapping[str, Any] | None, default: None) – Mapping of TAP_SCHEMA table name to its SQLAlchemy table object.

  • tap_schema_index (int | None, default: None) – The index of the schema for this TAP environment.

Methods Summary

check_column(column_obj)

Check consistency of VOTable attributes for a column.

from_mock_connection(mock_connection[, ...])

Create a TAP visitor from a mock connection.

visit_column(column_obj, table_obj)

Visit a column object and build its TAP_SCHEMA representation.

visit_constraint(constraint_obj)

Visit a constraint object and build its TAP_SCHEMA representation.

visit_constraints(schema_obj)

Visit all constraints in a schema.

visit_index(index_obj, table_obj)

Visit an index object and update the TAP_SCHEMA representation.

visit_primary_key(primary_key_obj, table_obj)

Visit a primary key object and update the TAP_SCHEMA representation.

visit_schema(schema_obj)

Visit a schema object and insert it into the TAP_SCHEMA database.

visit_table(table_obj, schema_obj)

Visit a table object and build its TAP_SCHEMA representation.

Methods Documentation

check_column(column_obj)

Check consistency of VOTable attributes for a column.

Parameters:

column_obj (Column) – The column object to check.

Return type:

None

Notes

This method checks that a column with a sized datatype has either a votable:arraysize or a length attribute and issues a warning message if not. It also checks if a column with a timestamp datatype has a arraysize attribute and issues a warning if not.

classmethod from_mock_connection(mock_connection, catalog_name=None, schema_name=None, tap_tables=None, tap_schema_index=None)

Create a TAP visitor from a mock connection.

Parameters:
  • mock_connection (MockConnection) – Mock connection object.

  • catalog_name (str | None, default: None) – Name of the database catalog.

  • schema_name (str | None, default: None) – Name of the database schema.

  • tap_tables (MutableMapping[str, Any] | None, default: None) – Optional mapping of table name to its SQLAlchemy table object.

  • tap_schema_index (int | None, default: None) – The index of the schema for this TAP environment.

Returns:

The TAP loading visitor.

Return type:

TapLoadingVisitor

visit_column(column_obj, table_obj)

Visit a column object and build its TAP_SCHEMA representation.

Parameters:
  • column_obj (Column) – The column object to visit.

  • table_obj (Table) – The table object which the column belongs to.

Returns:

The SQLAlchemy ORM object for the column.

Return type:

Tap11Base

visit_constraint(constraint_obj)

Visit a constraint object and build its TAP_SCHEMA representation.

Parameters:

constraint_obj (Constraint) – The constraint object to visit.

Returns:

A tuple of the SQLAlchemy ORM objects for the TAP_SCHEMA key and key_columns data.

Return type:

tuple

visit_constraints(schema_obj)

Visit all constraints in a schema.

Parameters:

schema_obj (Schema) – The schema object to visit.

Returns:

A tuple of all TAP_SCHEMA keys and key columns that were created.

Return type:

tuple

visit_index(index_obj, table_obj)

Visit an index object and update the TAP_SCHEMA representation.

Parameters:
  • index_obj (Index) – The index object to visit.

  • table_obj (Table) – The table object which the index belongs to.

Return type:

None

visit_primary_key(primary_key_obj, table_obj)

Visit a primary key object and update the TAP_SCHEMA representation.

Parameters:
  • primary_key_obj (str | Iterable[str] | None) – The primary key object to visit.

  • table_obj (Table) – The table object which the primary key belongs to.

Return type:

None

visit_schema(schema_obj)

Visit a schema object and insert it into the TAP_SCHEMA database.

Parameters:

schema_obj (Schema) – The schema object to visit.

Return type:

None

visit_table(table_obj, schema_obj)

Visit a table object and build its TAP_SCHEMA representation.

Parameters:
  • table_obj (Table) – The table object to visit.

  • schema_obj (Schema) – The schema object which the table belongs to.

Returns:

A tuple of the SQLAlchemy ORM objects for the tables and columns.

Return type:

tuple