| | import os |
| | import sys |
| | import logging |
| | import asyncio |
| |
|
| | |
| | |
| | sys.path.insert(0, '/app') |
| |
|
| | from core.discovery import discover_all_schemas |
| | from core.graph import import_schema, close_graph_driver |
| |
|
| | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
| | logger = logging.getLogger(__name__) |
| |
|
| | async def main(): |
| | """ |
| | Main asynchronous function to run the full schema discovery and ingestion process. |
| | """ |
| | logger.info("Starting schema ingestion process...") |
| | |
| | try: |
| | |
| | logger.info("Discovering schemas from all databases...") |
| | all_schemas = await discover_all_schemas() |
| | |
| | if not all_schemas: |
| | logger.warning("No schemas were discovered. Ingestion cannot proceed.") |
| | return |
| |
|
| | logger.info(f"Discovered {len(all_schemas)} schemas. Now ingesting into Neo4j...") |
| |
|
| | |
| | for schema_data in all_schemas: |
| | try: |
| | import_schema(schema_data) |
| | logger.info(f"Successfully ingested schema for: {schema_data['database_name']}") |
| | except Exception as e: |
| | logger.error(f"Failed to ingest schema for {schema_data['database_name']}: {e}", exc_info=True) |
| | |
| | logger.info("Schema ingestion process completed successfully.") |
| |
|
| | except Exception as e: |
| | logger.critical(f"A critical error occurred during the ingestion process: {e}", exc_info=True) |
| | finally: |
| | |
| | close_graph_driver() |
| | logger.info("Neo4j connection closed.") |
| |
|
| | if __name__ == "__main__": |
| | asyncio.run(main()) |
| |
|