dpmcore.loaders.migration
Migration service for importing Access databases into any SQLAlchemy-supported database.
Note
MigrationService lives in dpmcore.loaders (it mutates
the database), not in dpmcore.services (which are read-only).
It is still re-exported from dpmcore.services for backward
compatibility, but the canonical import is
from dpmcore.loaders.migration import MigrationService.
MigrationService
- class dpmcore.loaders.migration.MigrationService(engine, schema=None)[source]
Bases:
objectMigrate an Access database into a SQLAlchemy-managed database.
Unlike other dpmcore services that accept a
Session, this service requires anEnginebecause it needs to runBase.metadata.create_allandDataFrame.to_sql.- migrate_from_access(access_path, *, output_path=None)[source]
Extract tables from access_path and load into the database.
- Parameters:
- Return type:
- Returns:
A
MigrationResultwith details of what was loaded.- Raises:
MigrationError – If neither mdb-tools nor pyodbc can read the file.
- migrate_from_csv_dir(csv_dir, *, output_path=None)[source]
Load every CSV file from csv_dir into the target database.
- Parameters:
csv_dir (
str) – Directory containing one CSV file per table.output_path (
Optional[Path]) – Optional final path for the resulting SQLite file. Seemigrate_from_access()for details.
- Return type: