1234567891011121314151617181920212223242526272829303132333435363738 |
- """Transform and transfer tables from src to target database."""
- import sys
- import logging
- from almirah import Database
- from almirah.database import migrate
- from almirah.utils.gen import read_multi_yaml
- logging.basicConfig(filename="logs/migrate_from_raw_db.log", level=logging.DEBUG)
- logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
- src = Database(name="", backend="", host="")
- target = Database(name="", backend="", host="")
- src.connect("", "")
- target.connect("", "")
- mapping = "configs/mappings/transfer_db.yaml"
- dtype_kws = {
- "format": "mixed",
- }
- migrate(
- src,
- target,
- read_multi_yaml(mapping),
- dry_run=False,
- na_vals=[","],
- dtype_kws=dtype_kws,
- check_dups=True,
- resolve_dups=False,
- check_fks=True,
- resolve_fks=True,
- insert_ignore=True,
- )
|