meta_collector.meta_collector

CreationMode Objects

class CreationMode(Enum)

Enum for the different possibilities to use the MetaCollector.

0 -> don't create table, 1 -> create temporary table, 2 -> create permanent table

MetaCollector Objects

class MetaCollector()

Class for MetaCollector.

__init__

def __init__(database_connector: DatabaseConnector, debug: bool = False)

Initializer for the MetaCollector

Arguments:

  • database_connector: The connector to the used database.
  • debug: boolean whether to print additional information while processing

get_columns_data_postgres

def get_columns_data_postgres(table_names: List[str or Tuple[str, str]], columns: List[str]) -> List[Tuple[str, str, str, Tuple[int, int, int], Dict[str, LabelEncoder], str]]

Get column-name and datatype for the requested columns of the corresponding tables for PostgreSQL and MariaDB.

Arguments:

second place, to join.
  • table_names: List of names of tables, as strings or tuples containing table-name in first and alias in
  • columns: Columns to project on.

Returns:

A list containing the name of the column, the table alias (if existent, else the table-name), the

get_columns_data_sqlite

def get_columns_data_sqlite(table_names: List[str or Tuple[str, str]], columns: List[str]) -> List[Tuple[str, str, str, Tuple[int, int, int], Dict[str, LabelEncoder], str]]

Get column-name and datatype for the requested columns of the corresponding tables for SQLite.

Arguments:

second place, to join.
  • table_names: List of names of tables, as strings or tuples containing table-name in first and alias in
  • columns: Columns to project on.

Returns:

A list containing the name of the column, the table alias (if existent, else the table-name), the

collect_min_max_step

def collect_min_max_step(tablename: str, column: Tuple[str, str]) -> (Tuple[int, int, int], Dict)

After collecting the datatype information for the columns this function returns the min and max values for the meta-table and the encoders.

Arguments:

  • tablename: String containing the name of the table where to find the column
  • column: a tuple containing the name and the datatype for the column, each as string

Returns:

first: dictionary with the attribute-name as key and a tuple containing min-value, max-value and

get_max_card

def get_max_card(table_names: List[str or Tuple[str, str]], join_atts: List[str or Tuple[str, str]] = None) -> int

Get the size of the join-table without any selections, the so called max-card.

Arguments:

second place, to join.
join the tables on. -> is optional, because there is no join if there is only one table and so there would
be no join-attribute needed in that case
  • table_names: List of names of tables, as strings or tuples containing table-name in first and alias in
  • join_atts: List of attributes, as strings or tuples containing the two attributes to join with '=', to

Returns:

setup_view

def setup_view(table_names: List[str or Tuple[str, str]], columns_types: List[Tuple], join_atts: List[str or Tuple[str, str]] = None, cube: bool = False, mode: CreationMode = CreationMode.NONE) -> (List[Tuple[str, str]], int)

Create the tables tmpview and if cube==True also tmpview_cube containing the metadata for the given tables joined on the attributes and projected on the columns.

Arguments:

second place, to join.
join the tables on. -> is optional, because there is no join if there is only one table and so there would
be no join-attribute needed in that case
  • table_names: List of names of tables, as strings or tuples containing table-name in first and alias in
  • columns_types: columns to project on
  • join_atts: List of attributes, as strings or tuples containing the two attributes to join with '=', to
  • cube: boolean whether to create the *_cube table, too
  • mode: see CreationMode-Enum

Returns:

first: a list of tuples containing the name and the datatype for the columns, each as string

setup_cube_view

def setup_cube_view(new_table_name: str, columns)

Create the table tmpview_cube if cube==True containing the metadata for the given tables joined on the attributes and projected on the columns.

Arguments:

  • new_table_name: The name of the before created table.
  • columns: Columns to project on.

get_meta

def get_meta(table_names: List[str or Tuple[str, str]], columns: List[str], join_atts: List[str or Tuple[str, str]] = None, mode: CreationMode = CreationMode.NONE, save: bool = True, save_file_name: str = None, batchmode: bool = False, cube: bool = False) -> Dict

Method for the whole process of collecting the meta-information for the given tables joined on the given attributes and projected on the given columns.

Arguments:

second place, to join.
join the tables on. -> is optional, because there is no join if there is only one table and so there would
be no join-attribute needed in that case
mode
  • table_names: List of names of tables, as strings or tuples containing table-name in first and alias in
  • columns: List of names of columns, as strings, to project on.
  • join_atts: List of attributes, as strings or tuples containing the two attributes to join with '=', to
  • save: boolean whether to save the meta-information to file
  • save_file_name: name for the save-file for the meta_information -> not needed if save==False
  • batchmode: whether the meta data is collected in batches or not -> connection to db held open if batch
  • mode: see CreationMode-Enum
  • cube: Whether to create the _cube table additionally (only for CreationMode Temporary or Permanent).

Returns:

dictionary containing the meta-information

get_meta_from_file

def get_meta_from_file(file_path: str, save: bool = True, save_file_path: str = None, mode: CreationMode = CreationMode.NONE, override: bool = True) -> Dict[int, any]

Method for collecting meta data for the information given in a file from QueryParser or at least a file formatted like this.

Arguments:

  • file_path: Path to the file. Format has to be the same like the output of QueryParser
  • save: Whether to save the information to file or not. -> It is recommended to do so.
  • save_file_path: Optional path for the save-file.
  • mode: see CreationMode-Enum
  • override: Whether to override an already existing meta_information file.

Returns:

The solution dict.

save_meta

def save_meta(meta_dict: Dict, file_name: str = "meta_information", mode: str = "w")

Method for saving the meta-information to file.

Arguments:

  • meta_dict: the dictionary containing the meta-information to save
  • file_name: the name (without file-type) for the save-file
  • mode: The mode to open the file. Some common possibilities are 'w', 'w+', 'r', 'a', 'a+'

results matching ""

    No results matching ""