diff --git a/src/alpine_bits_python/util/migrate_sqlite_to_postgres.py b/src/alpine_bits_python/util/migrate_sqlite_to_postgres.py index 39e963b..84ff22d 100644 --- a/src/alpine_bits_python/util/migrate_sqlite_to_postgres.py +++ b/src/alpine_bits_python/util/migrate_sqlite_to_postgres.py @@ -42,6 +42,7 @@ from pathlib import Path # Add parent directory to path so we can import alpine_bits_python sys.path.insert(0, str(Path(__file__).parent.parent.parent)) +import yaml from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine @@ -418,14 +419,19 @@ async def main(): if args.target: target_url = args.target elif args.target_config: - # Load target config file + # Load target config file manually (simpler YAML without secrets) _LOGGER.info("Loading target database config from: %s", args.target_config) try: - target_config = load_config(args.target_config) - target_url = get_database_url(target_config) + config_path = Path(args.target_config) + with config_path.open() as f: + target_config = yaml.safe_load(f) + target_url = target_config["database"]["url"] _LOGGER.info("Successfully loaded target config") except (FileNotFoundError, ValueError, KeyError): _LOGGER.exception("Failed to load target config") + _LOGGER.info( + "Config file should contain: database.url with PostgreSQL connection" + ) sys.exit(1) else: import os