from psycopg2.sql import SQL from anaxi.config import ( get_cosmos_database_config_from_file, get_postgres_database_config_from_file, ) from anaxi.cosmos_tools import create_cosmos_client_from_config from anaxi.logging import get_anaxi_logger from anaxi.postgres_tools import simply_query from anaxi.sync import SyncJob logger = get_anaxi_logger(__name__) def run_cosmos_db_healthcheck_process(cosmos_db_id: str) -> None: relevant_cosmos_db_config = get_cosmos_database_config_from_file(cosmos_db_id) logger.info("Creating client...") cosmos_client = create_cosmos_client_from_config(relevant_cosmos_db_config) logger.info("Client created.") logger.info("Sending a SELECT 1;") response = cosmos_client.query_databases(query="SELECT 1") logger.info(f"Response: {response.next()}") return def run_postgres_healthcheck_process(postgres_database: str) -> None: relevant_postgres_config = get_postgres_database_config_from_file(postgres_database) logger.info("Connecting and sending a SELECT 1...") query_result = simply_query(config=relevant_postgres_config, query=SQL("SELECT 1;")) logger.info(f"Response: {query_result}") return def run_sync_process(stream_id: str) -> None: logger.info("Preparing sync job...") sync_job = SyncJob(stream_id=stream_id) logger.info("Sync job ready.") logger.info(f"Checkpoint is at: {sync_job.current_checkpoint}") sync_job.run_sync()