TableManager¶
- class felis.tap_schema.TableManager(engine=None, schema_name=None, apply_schema_to_metadata=True, table_name_postfix='')¶
Bases:
object
Manage creation of TAP_SCHEMA tables.
- Parameters:
engine (
Engine
|MockConnection
|None
, default:None
) – The SQLAlchemy engine for reflecting the TAP_SCHEMA tables from an existing database. This can be a mock connection or None, in which case the internal TAP_SCHEMA schema will be used by loading an internal YAML file.schema_name (
str
|None
, default:None
) – The name of the schema to use for the TAP_SCHEMA tables. Leave as None to use the standard name of “TAP_SCHEMA”.apply_schema_to_metadata (
bool
, default:True
) – If True, apply the schema to the metadata as well as the tables. If False, these will be set to None, e.g., for sqlite.table_name_postfix (
str
, default:''
) – A string to append to all the standard table names. This needs to be used in a way such that the resultant table names map to tables within the TAP_SCHEMA database.
Notes
The TAP_SCHEMA schema must either have been created already, in which case the
engine
should be provided. Or the internal TAP_SCHEMA schema will be used ifengine
is None or aMockConnection
.Attributes Summary
Get the metadata for the TAP_SCHEMA tables.
Get the TAP_SCHEMA schema.
Methods Summary
Get the standard schema name for the TAP_SCHEMA tables.
Get the standard column names for the TAP_SCHEMA tables.
Get the path to the standard TAP_SCHEMA schema resource.
Get the standard TAP_SCHEMA schema resource.
initialize_database
(engine)Initialize a database with the TAP_SCHEMA tables.
Load the standard TAP_SCHEMA schema from a Felis package resource into a Felis
Schema
.Attributes Documentation
- metadata¶
Get the metadata for the TAP_SCHEMA tables.
- Returns:
The metadata for the TAP_SCHEMA tables.
- Return type:
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:
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:
- 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:
- 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:
- classmethod get_tap_schema_std_resource()¶
Get the standard TAP_SCHEMA schema resource.
- Returns:
The standard TAP_SCHEMA schema resource.
- Return type:
- initialize_database(engine)¶
Initialize a database with the TAP_SCHEMA tables.