Example #1
0
def _load_table(table: Model, directory: Path, format_: str):
    """Dump a single table."""

    if directory is not None:
        print(f"    Loading {table.table_name()}...")
        in_file = Path(directory) / f"{table.table_name()}.{format_}"
        dataset = tablib.Dataset(headers=table.fields()).load(
            in_file.read_text())
        print(f"    Importing {table.table_name()} into the database...")
        table.insert_many(dataset.dict).execute()
        print("    Done.")
        print("=====================")
    else:
        pass