dpmcore.services.export_csv

Export every user table from a Microsoft Access .accdb / .mdb file to individual CSV files. Tables are exported in parallel.

Note

Requires the migration extra and mdb-tools on PATH.

ExportCsvService

class dpmcore.services.export_csv.ExportCsvService[source]

Bases: object

Export all user tables from a Microsoft Access file to CSV files.

Requires mdb-tools (mdb-tables + mdb-export) to be installed.

export(access_path, output_dir)[source]

Export every user table in access_path to output_dir.

Parameters:
  • access_path (str) – Filesystem path to an .accdb or .mdb file.

  • output_dir (Path) – Directory where <TableName>.csv files are written. Created (including parents) if it does not exist.

Return type:

ExportCsvResult

Returns:

An ExportCsvResult describing what was exported.

Raises:

ExportCsvError – If mdb-tools is not available or the file cannot be read.

export_safely(access_path, output_dir)[source]

Safely export Access tables, replacing the output dir at the end.

Return type:

ExportCsvResult

Parameters:
  • access_path (str)

  • output_dir (Path)

ExportCsvResult

class dpmcore.services.export_csv.ExportCsvResult(tables_exported, output_dir, table_names=<factory>)[source]

Outcome of a successful export run.

Parameters:
tables_exported: int
output_dir: Path
table_names: List[str]

ExportCsvError

exception dpmcore.services.export_csv.ExportCsvError[source]

Bases: Exception

Raised when CSV export cannot proceed.