leaguemanager.services.template_loader.league_importer

Module Contents

Classes

Importer

Protocol for importers that can load data into the database.

InputModels

A class that enables all importer classes to pre-instantiate models as usable attributes based on the user’s template data

ExcelLoader

A class to load data from Excel files into the database.

CSVLoader

A class to load data from CSV files into the database.

JSONLoader

A class to load data from JSON files into the database.

GoogleSheetsLoader

A class to load data from Google Sheets into the database.

MemoryLoader

A class to load data from memory into the database.

Functions

convert_str_to_path

Convert a string to a Path object.

Data

logger

__all__

API

leaguemanager.services.template_loader.league_importer.logger

‘getLogger(…)’

leaguemanager.services.template_loader.league_importer.__all__

[‘ExcelLoader’, ‘CSVLoader’, ‘JSONLoader’, ‘GoogleSheetsLoader’, ‘MemoryLoader’]

class leaguemanager.services.template_loader.league_importer.Importer

Bases: typing.Protocol

Protocol for importers that can load data into the database.

load() None

Load data into the database.

validate() None

Validate the data before loading it into the database.

write_to_db() None

Write data to the database.

leaguemanager.services.template_loader.league_importer.convert_str_to_path(value: str | pathlib.Path) pathlib.Path

Convert a string to a Path object.

class leaguemanager.services.template_loader.league_importer.InputModels

A class that enables all importer classes to pre-instantiate models as usable attributes based on the user’s template data

org_model: List[leaguemanager.models.Organization]

None

league_models: List[leaguemanager.models.League]

None

season_models: List[leaguemanager.models.Season]

None

team_membership_models: List[leaguemanager.models.TeamMembership]

None

team_models: List[leaguemanager.models.Team]

None

class leaguemanager.services.template_loader.league_importer.ExcelLoader

A class to load data from Excel files into the database.

file_path: str | pathlib.Path | None

‘field(…)’

league_manager_registry: leaguemanager.LeagueManager | None

‘field(…)’

load(template_type: str = 'tabulated') leaguemanager.services.template_loader.league_importer.InputModels

Load data from an Excel file into Python.

abstract validate() None

Validate the data before loading it into the database.

property write_to_db: None

Write data to the database.

property registry: leaguemanager.LeagueManager

Get the LeagueManager registry.

property org_service: leaguemanager.services.OrganizationService

Get the org service with the session already attached

property league_service: leaguemanager.services.LeagueService

Get the league service with the session already attached

property season_service: leaguemanager.services.SeasonService

Get the season service with the session already attached

property team_service: leaguemanager.services.TeamService

Get the team service with the session already attached

property team_membership_service: leaguemanager.services.TeamMembershipService

Get the team membership service with the sessions already attached

property _transform_tabulated_data: dict

Transform dataframe to hierarchical dictionary structure

class leaguemanager.services.template_loader.league_importer.CSVLoader

A class to load data from CSV files into the database.

file_path: str | pathlib.Path | None

‘field(…)’

abstract load(data: dict) None

Load data from a CSV file into the database.

abstract validate(data: dict) None

Validate the data before loading it into the database.

abstract write_to_db(data: dict) None

Write data to the database.

class leaguemanager.services.template_loader.league_importer.JSONLoader

A class to load data from JSON files into the database.

file_path: str | pathlib.Path | None

‘field(…)’

abstract load(data: dict) None

Load data from a JSON file into the database.

abstract validate(data: dict) None

Validate the data before loading it into the database.

abstract write_to_db(data: dict) None

Write data to the database.

class leaguemanager.services.template_loader.league_importer.GoogleSheetsLoader

A class to load data from Google Sheets into the database.

sheet_id: str | None

‘field(…)’

spreadsheet_name: str | None

‘field(…)’

Name of the Google Sheets spreadsheet to load data from.

abstract load(data: dict) None

Load data from a Google Sheet into the database.

abstract validate(data: dict) None

Validate the data before loading it into the database.

abstract write_to_db(data: dict) None

Write data to the database.

class leaguemanager.services.template_loader.league_importer.MemoryLoader

A class to load data from memory into the database.

data: dict | None

‘field(…)’

load(data: dict) None

Load data from memory into the database.

abstract validate(data: dict) None

Validate the data before loading it into the database.

abstract write_to_db(data: dict) None

Write data to the database.