TableManager

class felis.tap_schema.TableManager(engine_url=None, db_context=None, schema_name=None, table_name_postfix='', extensions_path=None)

Bases: object

Manage TAP_SCHEMA table definitions and access.

This class provides a streamlined interface for managing TAP_SCHEMA tables, automatically handling dialect-specific requirements and providing consistent access to TAP_SCHEMA tables through a dictionary-like interface.

Parameters:
  • engine_url (str | None, default: None) – Database engine URL for automatic dialect detection and schema handling.

  • db_context (DatabaseContext | None, default: None) – Optional database context for reflecting existing TAP_SCHEMA tables. If None, loads from internal YAML schema.

  • schema_name (str | None, default: None) – The name of the schema to use for TAP_SCHEMA tables. Defaults to “TAP_SCHEMA”.

  • table_name_postfix (str, default: '') – A string to append to standard table names for customization.

  • extensions_path (str | None, default: None) – Path to additional TAP_SCHEMA table definitions.

Notes

The TableManager automatically detects SQLite vs. schema-supporting databases and handles schema application appropriately.

Attributes Summary

metadata

Get the metadata for the TAP_SCHEMA tables.

schema

Get the TAP_SCHEMA schema.

Methods Summary

get_schema_name_std()

Get the standard schema name for the TAP_SCHEMA tables.

get_table_names_std()

Get the standard column names for the TAP_SCHEMA tables.

get_tap_schema_std_path()

Get the path to the standard TAP_SCHEMA schema resource.

get_tap_schema_std_resource()

Get the standard TAP_SCHEMA schema resource.

initialize_database(db_context)

Initialize a database with the TAP_SCHEMA tables.

load_schema_resource()

Load the standard TAP_SCHEMA schema from a Felis package resource into a Felis Schema.

select(db_context, table_name[, ...])

Select all rows from a TAP_SCHEMA table with an optional filter condition.

Attributes Documentation

metadata

Get the metadata for the TAP_SCHEMA tables.

Returns:

The metadata for the TAP_SCHEMA tables.

Return type:

MetaData

Notes

This will either be the metadata that was reflected from an existing database or the metadata that was loaded from a Felis package resource.

schema

Get the TAP_SCHEMA schema.

Returns:

The TAP_SCHEMA schema.

Return type:

Schema

Notes

This will only be set if the TAP_SCHEMA schema was loaded from a Felis package resource. In the case where the TAP_SCHEMA schema was reflected from an existing database, this will be None.

Methods Documentation

classmethod get_schema_name_std()

Get the standard schema name for the TAP_SCHEMA tables.

Returns:

The standard schema name for the TAP_SCHEMA tables.

Return type:

str

classmethod get_table_names_std()

Get the standard column names for the TAP_SCHEMA tables.

Returns:

The standard table names for the TAP_SCHEMA tables.

Return type:

list

classmethod get_tap_schema_std_path()

Get the path to the standard TAP_SCHEMA schema resource.

Returns:

The path to the standard TAP_SCHEMA schema resource.

Return type:

str

classmethod get_tap_schema_std_resource()

Get the standard TAP_SCHEMA schema resource.

Returns:

The standard TAP_SCHEMA schema resource.

Return type:

ResourcePath

initialize_database(db_context)

Initialize a database with the TAP_SCHEMA tables.

Parameters:

db_context (DatabaseContext) – The database context to use to create the tables.

Return type:

None

classmethod load_schema_resource()

Load the standard TAP_SCHEMA schema from a Felis package resource into a Felis Schema.

Returns:

The TAP_SCHEMA schema.

Return type:

Schema

select(db_context, table_name, filter_condition='')

Select all rows from a TAP_SCHEMA table with an optional filter condition.

Parameters:
  • db_context (DatabaseContext) – The database context to use to connect to the database.

  • table_name (str) – The name of the table to select from.

  • filter_condition (str, default: '') – The filter condition as a string. If empty, no filter will be applied.

Returns:

A list of dictionaries containing the rows from the table.

Return type:

list