migrate_from_raw_db.py 817 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. """Transform and transfer tables from src to target database."""
  2. import sys
  3. import logging
  4. from almirah import Database
  5. from almirah.database import migrate
  6. from almirah.utils.gen import read_multi_yaml
  7. logging.basicConfig(filename="logs/migrate_from_raw_db.log", level=logging.DEBUG)
  8. logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
  9. src = Database(name="", backend="", host="")
  10. target = Database(name="", backend="", host="")
  11. src.connect("", "")
  12. target.connect("", "")
  13. mapping = "configs/mappings/transfer_db.yaml"
  14. dtype_kws = {
  15. "format": "mixed",
  16. }
  17. migrate(
  18. src,
  19. target,
  20. read_multi_yaml(mapping),
  21. dry_run=False,
  22. na_vals=[","],
  23. dtype_kws=dtype_kws,
  24. check_dups=True,
  25. resolve_dups=False,
  26. check_fks=True,
  27. resolve_fks=True,
  28. insert_ignore=True,
  29. )