
How to Use SQL2Graph Agentic Migration Tool: A Step-by-Step Guide
Most data in enterprises lives in Relational Databases. It is structured, but disconnected. GraphRAG, on the other hand, needs connected context. That is where SQL2Graph, part of the Memgraph AI Toolkit, comes in.
SQL2Graph is an agentic migration tool that automates the process of converting relational databases (PostgreSQL or MySQL, in particular) into graph structures inside Memgraph. It helps you move from tables and joins to relationships and knowledge graphs.
In this detailed guide, we will walk you through how to use the SQL2Graph migration agent step by step. You will see how you can speed up your SQL to Graph migration by 10 times and get started with your GraphRAG projects.
What is SQL2Graph?
SQL2Graph bridges the gap between structured data in SQL or PostgresSQL databases and graph databases. It’s part of the Memgraph AI Toolkit and serves as an agentic migration tool that automatically converts relational databases into graph structures inside Memgraph.
Instead of manually mapping tables and foreign keys, SQL2Graph uses HyGM-powered agents to infer relationships, detect meaningful connections, and build a queryable knowledge graph that can become a foundation for your GraphRAG pipelines.
Read More: SQL2Graph Agentic Migration: From Relational Thinking to Graph Reasoning
Step 1: Clone the Memgraph AI Toolkit
Start by preparing your workspace and running Memgraph:
- Sign up to Memgraph Cloud.
- Create a new project. This will launch a Memgraph instance hosted in the cloud.
- Once it’s ready, copy your connection credentials (host URL, username, and password). You’ll use them to connect from your local environment.
- Open your terminal, VS Code, Cursor, or any other development environment you prefer. This is to run Python scripts connected to your Memgraph Cloud instance.
Now, you need to clone the Memgraph AI Toolkit from GitHub. It contains the SQL2Graph migration agent and supporting scripts.
# Clone the repository
git clone https://github.com/memgraph/ai-toolkit
# Navigate to the sql2graph directory
cd agents/sql2graphStep 2: Install Dependencies
SQL2Graph uses uv, a lightweight Python package manager, for dependency management.
# Install dependencies using uv
uv pip install -e .Check out its quick start guide.
Step 3: Set Up Your Configuration
Create a .env file that specifies your source SQL database and target Memgraph Cloud instance. This tells the agent where to pull data from and where to migrate it. You need to fill in the following variables:
# Source Database
SOURCE_DB_TYPE=postgresql # or mysql
# PostgreSQL Configuration
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DATABASE=mydb
POSTGRES_USER=username
POSTGRES_PASSWORD=password
POSTGRES_SCHEMA=public
# MySQL Configuration (if using MySQL)
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_DATABASE=mydb
MYSQL_USER=username
MYSQL_PASSWORD=password
# Target Memgraph Database
MEMGRAPH_URL=bolt+ssc://<your-cloud-instance>:7687
MEMGRAPH_USERNAME=<your_username>
MEMGRAPH_PASSWORD=<your_password>
MEMGRAPH_DATABASE=memgraph
# LLM API Keys (for AI-powered features)
# Only provide the key for your chosen provider
OPENAI_API_KEY=sk-... # For GPT models
# ANTHROPIC_API_KEY=sk-ant-... # For Claude models
# GOOGLE_API_KEY=AI... # For Gemini models
# Optional: Specify LLM model (defaults shown)
# LLM_MODEL=gpt-4o-mini # OpenAI default
# LLM_MODEL=claude-3-5-sonnet-20241022 # Anthropic default
# LLM_MODEL=gemini-2.0-flash-exp # Google default
# Migration Defaults (can be overridden via CLI flags)
SQL2MG_MODE=automatic # Options: automatic, incremental
SQL2MG_STRATEGY=deterministic # Options: deterministic, llm
SQL2MG_META_POLICY=auto # Options: auto, reset, skip
SQL2MG_LOG_LEVEL=INFOSQL2Graph currently supports MySQL and PostgresSQL data sources. Here is an environment example file available for your reference.
💡 Important Note: Network Visibility for SQL2Graph Migration
When using SQL2Graph with Memgraph Cloud, the Memgraph server must be able to access your SQL instance to perform the migration. This means your SQL database needs to be network-accessible (publicly reachable) to the Memgraph Cloud instance.
However, publicly reachable does not mean unsecured. You can (and should) protect the SQL instance using authentication (username and password).
In short:
- For Cloud migrations: ensure your SQL instance is accessible from outside your local network (public-protected).
- For local setups: you can run both SQL and Memgraph locally (via Docker) if your data cannot be exposed externally.
This configuration flexibility allows you to experiment safely with Cloud migrations while keeping sensitive environments secure.
Step 4: Choose a Migration Mode
You can choose between two modes depending on how hands-on you want to be:
- Automatic Mode: Ideal for quick migrations of straightforward schemas. The agent performs a one-shot migration without your input.
- Incremental Mode: Gives you full control, allowing you to review, edit, and refine your graph model interactively. Ideal for complex environments
You can choose what suits you best.
Step 5: Pick Your Modeling Strategy
Once you choose the mode, you need to pick your modeling strategy:
- Deterministic: Rule-based conversion that is predictable and stable. Ideal for production pipelines.
- AI-Powered (HyGM): The LLM-driven approach that iteratively proposes, refines, and validates graph schemas changes and optimizations. Great for experimentation.
HyGM stands for Hypothetical Graph Modeling. It is the engine behind the AI insided modeling strategy that interprets your database schema, proposes a suitable graph model, and validates it before migration. While it is still experimental, it is powerful for schema discovery and rapid prototyping.
Read more: Introducing HyGM: The Agentic Graph Modeling Framework Powering SQL2Graph
Step 6: Run the MigrationAgent
Run the migration agent using:
uv run main.pyYou will see logs validating connections to both SQL and Memgraph. The agent automatically detects your database schema and begins the transformation. The .env configuration can also define the migration mode and modeling strategy, which is determined via the SQL2MG_MODE and SQL2MG_STRATEGY variables. Here is a full list of environment variables you can change during the migration process.
Depending on the environment specification, the agent will interactively guide you through:
-
Environment validation: Verifies database connections
-
Mode selection: Choose automatic or incremental migration
-
Strategy selection: Pick deterministic or AI-powered modeling
-
Schema analysis: Automatically discovers your database structure
-
Graph model generation: Creates the optimal graph schema
-
Data migration: Transfers data with progress tracking
-
Validation: Confirms migration success and data integrity
You can also use the CLI to select options:
# Fully configured non-interactive run
uv run main.py \
--mode automatic \
--strategy deterministic \
--meta-graph reset \
--log-level INFOThis is what you would see as an output:
(memgraph-ai) ➜ sql2graph git:(main) ✗ uv run main.py
============================================================
🚀 SQL Database to Graph Migration Agent
============================================================
Intelligent database migration with LLM-powered analysis
🔧 Setting up environment...
2025-10-29 13:36:16,414 - utils.environment - INFO - Environment variables loaded successfully
✅ Environment validation completed
🔌 Testing database connections...
2025-10-29 13:36:16,414 - utils.environment - INFO - Validating LLM provider API keys...
2025-10-29 13:36:17,855 - httpx - INFO - HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
2025-10-29 13:36:17,871 - utils.environment - INFO - ✅ Valid LLM providers: OpenAI
2025-10-29 13:36:17,871 - utils.environment - INFO - Testing Mysql connection...
2025-10-29 13:36:17,932 - database.adapters.mysql - INFO - Successfully connected to MySQL database
2025-10-29 13:36:18,689 - database.adapters.mysql - INFO - MySQL connection closed
2025-10-29 13:36:18,690 - utils.environment - INFO - ✅ Mysql connection successful to sakila@localhost
2025-10-29 13:36:18,690 - utils.environment - INFO - Testing Memgraph connection...
2025-10-29 13:36:18,703 - utils.environment - INFO - ✅ Memgraph connection successful to bolt://localhost:7687
✅ All connections verified
Graph modeling mode:
1. Automatic - Generate graph model without prompts
2. Incremental - Review each table with end-of-session refinement
Select mode (1-2) or press Enter for automatic: 1
Graph modeling strategy:
1. Deterministic - Rule-based graph model creation
2. AI - LLM-based graph model creation (full HyGM capabilities)
Select strategy (1-2) or press Enter for deterministic: 1
🔧 Creating migration agent...
🎯 Graph modeling: automatic with deterministic strategy
🚀 Starting migration workflow...
This will:
1. 🔍 Analyze source database schema
2. 🎯 Generate graph model with HyGM
3. 📝 Create indexes and constraints
4. ⚙️ Generate migration queries
5. 🔄 Execute migration to Memgraph
6. ✅ Verify the migration results
2025-10-29 13:36:25,268 - core.migration_agent - INFO - Starting SQL database to graph migration...
2025-10-29 13:36:25,285 - core.migration_agent - INFO - Preparing database connection for HyGM analysis...
2025-10-29 13:36:25,293 - database.adapters.mysql - INFO - Successfully connected to MySQL database
2025-10-29 13:36:26,055 - core.migration_agent - INFO - Database structure prepared for HyGM analysis
2025-10-29 13:36:26,057 - core.migration_agent - INFO - Preparing target database for migration...
2025-10-29 13:36:26,066 - core.migration_agent - INFO - Memgraph connection established successfully
2025-10-29 13:36:26,072 - core.migration_agent - INFO - No existing migration metadata found for localhost/sakila
2025-10-29 13:36:26,072 - core.migration_agent - INFO - No migration metadata found; treating this as an initial run
2025-10-29 13:36:26,073 - core.migration_agent - INFO - Creating graph model using HyGM...
2025-10-29 13:36:26,073 - core.migration_agent - INFO - Using automatic graph modeling mode
2025-10-29 13:36:26,073 - core.migration_agent - INFO - Using deterministic graph modeling strategy
2025-10-29 13:36:26,073 - core.hygm.hygm - INFO - Creating graph model using deterministic strategy...
2025-10-29 13:36:26,073 - core.hygm.strategies.deterministic - INFO - Creating deterministic graph model...
2025-10-29 13:36:26,074 - core.migration_agent - INFO - Graph model created with 14 node types and 20 relationship types
2025-10-29 13:36:26,074 - core.migration_agent - INFO - Creating HyGM indexes and constraints...
2025-10-29 13:36:26,074 - core.migration_agent - INFO - Using HyGM-provided indexes and constraints
2025-10-29 13:36:26,074 - core.migration_agent - INFO - HyGM provided 39 indexes and 14 constraints
2025-10-29 13:36:26,074 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Actor) ASSERT n.actor_id IS UNIQUE
2025-10-29 13:36:26,079 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Address) ASSERT n.address_id IS UNIQUE
2025-10-29 13:36:26,080 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Category) ASSERT n.category_id IS UNIQUE
2025-10-29 13:36:26,083 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:City) ASSERT n.city_id IS UNIQUE
2025-10-29 13:36:26,085 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Country) ASSERT n.country_id IS UNIQUE
2025-10-29 13:36:26,088 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Customer) ASSERT n.customer_id IS UNIQUE
2025-10-29 13:36:26,091 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Film) ASSERT n.film_id IS UNIQUE
2025-10-29 13:36:26,094 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Film_Text) ASSERT n.film_id IS UNIQUE
2025-10-29 13:36:26,100 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Inventory) ASSERT n.inventory_id IS UNIQUE
2025-10-29 13:36:26,105 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Language) ASSERT n.language_id IS UNIQUE
2025-10-29 13:36:26,110 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Payment) ASSERT n.payment_id IS UNIQUE
2025-10-29 13:36:26,113 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Rental) ASSERT n.rental_id IS UNIQUE
2025-10-29 13:36:26,114 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Staff) ASSERT n.staff_id IS UNIQUE
2025-10-29 13:36:26,116 - core.migration_agent - INFO - Creating constraint: CREATE CONSTRAINT ON (n:Store) ASSERT n.store_id IS UNIQUE
2025-10-29 13:36:26,117 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Actor(actor_id)
2025-10-29 13:36:26,119 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Actor(last_name)
2025-10-29 13:36:26,121 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Address(location)
2025-10-29 13:36:26,123 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Address(city_id)
2025-10-29 13:36:26,125 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Address(address_id)
2025-10-29 13:36:26,127 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Category(category_id)
2025-10-29 13:36:26,128 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :City(country_id)
2025-10-29 13:36:26,130 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :City(city_id)
2025-10-29 13:36:26,132 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Country(country_id)
2025-10-29 13:36:26,133 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Customer(customer_id)
2025-10-29 13:36:26,135 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Customer(last_name)
2025-10-29 13:36:26,136 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Customer(store_id)
2025-10-29 13:36:26,138 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Customer(address_id)
2025-10-29 13:36:26,140 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Film(original_language_id)
2025-10-29 13:36:26,141 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Film(film_id)
2025-10-29 13:36:26,143 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Film(language_id)
2025-10-29 13:36:26,145 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Film(title)
2025-10-29 13:36:26,147 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Film_Text(film_id)
2025-10-29 13:36:26,148 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Film_Text(title)
2025-10-29 13:36:26,150 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Film_Text(description)
2025-10-29 13:36:26,151 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Inventory(film_id)
2025-10-29 13:36:26,152 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Inventory(store_id)
2025-10-29 13:36:26,154 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Inventory(inventory_id)
2025-10-29 13:36:26,155 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Language(language_id)
2025-10-29 13:36:26,156 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Payment(customer_id)
2025-10-29 13:36:26,158 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Payment(staff_id)
2025-10-29 13:36:26,159 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Payment(rental_id)
2025-10-29 13:36:26,161 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Payment(payment_id)
2025-10-29 13:36:26,162 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Rental(inventory_id)
2025-10-29 13:36:26,164 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Rental(rental_date)
2025-10-29 13:36:26,166 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Rental(customer_id)
2025-10-29 13:36:26,167 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Rental(staff_id)
2025-10-29 13:36:26,169 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Rental(rental_id)
2025-10-29 13:36:26,170 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Staff(store_id)
2025-10-29 13:36:26,171 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Staff(address_id)
2025-10-29 13:36:26,173 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Staff(staff_id)
2025-10-29 13:36:26,175 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Store(manager_staff_id)
2025-10-29 13:36:26,179 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Store(store_id)
2025-10-29 13:36:26,180 - core.migration_agent - INFO - Creating index: CREATE INDEX ON :Store(address_id)
2025-10-29 13:36:26,182 - core.migration_agent - INFO - Created 14 constraints and 39 indexes from HyGM model
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Generating Cypher queries based on HyGM graph model...
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::actor → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::address → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::category → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::city → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::country → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::customer → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::film → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::film_text → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::inventory → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::language → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::payment → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::rental → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::staff → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Node plan source::store → new node definition, table count unavailable previously
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::ACTOR_TO_FILM → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::ADDRESS_TO_CITY → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::CATEGORY_TO_FILM → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::CITY_TO_COUNTRY → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::CUSTOMER_TO_ADDRESS → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::CUSTOMER_TO_STORE → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::FILM_TO_LANGUAGE → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::INVENTORY_TO_FILM → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::INVENTORY_TO_STORE → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::PAYMENT_TO_CUSTOMER → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::PAYMENT_TO_RENTAL → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::PAYMENT_TO_STAFF → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::RENTAL_TO_CUSTOMER → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::RENTAL_TO_INVENTORY → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::RENTAL_TO_STAFF → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::STAFF_TO_ADDRESS → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::STAFF_TO_STORE → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::STORE_TO_ADDRESS → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Relationship plan source::STORE_TO_STAFF → new relationship definition, dependent node update
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Using migrate.mysql procedure for data ingestion
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Actor
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Address
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Category
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for City
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Country
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Customer
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Film
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Film_Text
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Inventory
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Language
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Payment
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Rental
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Staff
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for Store
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Preparing relationship queries for 20 definitions
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship ADDRESS_TO_CITY
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship CITY_TO_COUNTRY
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship CUSTOMER_TO_ADDRESS
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship CUSTOMER_TO_STORE
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship FILM_TO_LANGUAGE
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship FILM_TO_LANGUAGE
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship ACTOR_TO_FILM
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship CATEGORY_TO_FILM
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship INVENTORY_TO_FILM
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship INVENTORY_TO_STORE
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship PAYMENT_TO_CUSTOMER
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship PAYMENT_TO_RENTAL
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship PAYMENT_TO_STAFF
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship RENTAL_TO_CUSTOMER
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship RENTAL_TO_INVENTORY
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship RENTAL_TO_STAFF
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship STAFF_TO_ADDRESS
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship STAFF_TO_STORE
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship STORE_TO_ADDRESS
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Prepared merge query for relationship STORE_TO_STAFF
2025-10-29 13:36:26,183 - core.migration_agent - INFO - Generated 34 migration queries
2025-10-29 13:36:26,184 - core.migration_agent - INFO - Executing data migration...
2025-10-29 13:36:26,184 - core.migration_agent - INFO - Executing query 1/34...
2025-10-29 13:36:26,232 - core.migration_agent - INFO - Executing query 2/34...
2025-10-29 13:36:26,274 - core.migration_agent - INFO - Executing query 3/34...
2025-10-29 13:36:26,305 - core.migration_agent - INFO - Executing query 4/34...
2025-10-29 13:36:26,339 - core.migration_agent - INFO - Executing query 5/34...
2025-10-29 13:36:26,365 - core.migration_agent - INFO - Executing query 6/34...
2025-10-29 13:36:26,401 - core.migration_agent - INFO - Executing query 7/34...
2025-10-29 13:36:26,451 - core.migration_agent - INFO - Executing query 8/34...
2025-10-29 13:36:26,485 - core.migration_agent - INFO - Executing query 9/34...
2025-10-29 13:36:26,553 - core.migration_agent - INFO - Executing query 10/34...
2025-10-29 13:36:26,610 - core.migration_agent - INFO - Executing query 11/34...
2025-10-29 13:36:26,898 - core.migration_agent - INFO - Executing query 12/34...
2025-10-29 13:36:27,399 - core.migration_agent - INFO - Executing query 13/34...
2025-10-29 13:36:27,438 - core.migration_agent - INFO - Executing query 14/34...
2025-10-29 13:36:27,463 - core.migration_agent - INFO - Executing query 15/34...
2025-10-29 13:36:27,491 - core.migration_agent - INFO - Executing query 16/34...
2025-10-29 13:36:27,521 - core.migration_agent - INFO - Executing query 17/34...
2025-10-29 13:36:27,550 - core.migration_agent - INFO - Executing query 18/34...
2025-10-29 13:36:27,592 - core.migration_agent - INFO - Executing query 19/34...
2025-10-29 13:36:27,623 - core.migration_agent - INFO - Executing query 20/34...
2025-10-29 13:36:27,651 - core.migration_agent - INFO - Executing query 21/34...
2025-10-29 13:36:27,677 - core.migration_agent - INFO - Executing query 22/34...
2025-10-29 13:36:27,700 - core.migration_agent - INFO - Executing query 23/34...
2025-10-29 13:36:27,753 - core.migration_agent - INFO - Executing query 24/34...
2025-10-29 13:36:27,800 - core.migration_agent - INFO - Executing query 25/34...
2025-10-29 13:36:28,048 - core.migration_agent - INFO - Executing query 26/34...
2025-10-29 13:36:28,168 - core.migration_agent - INFO - Executing query 27/34...
2025-10-29 13:36:28,274 - core.migration_agent - INFO - Executing query 28/34...
2025-10-29 13:36:28,386 - core.migration_agent - INFO - Executing query 29/34...
2025-10-29 13:36:28,504 - core.migration_agent - INFO - Executing query 30/34...
2025-10-29 13:36:28,627 - core.migration_agent - INFO - Executing query 31/34...
2025-10-29 13:36:28,663 - core.migration_agent - INFO - Executing query 32/34...
2025-10-29 13:36:28,687 - core.migration_agent - INFO - Executing query 33/34...
2025-10-29 13:36:28,711 - core.migration_agent - INFO - Executing query 34/34...
2025-10-29 13:36:28,738 - core.migration_agent - INFO - Migration completed: 34/34 queries executed successfully
2025-10-29 13:36:28,739 - core.migration_agent - INFO - Running post-migration validation...
2025-10-29 13:36:28,739 - core.migration_agent - INFO - Executing post-migration validation...
2025-10-29 13:36:28,743 - core.hygm.validation.memgraph_data_validator - INFO - Retrieved actual schema: 14 nodes, 19 relationships
2025-10-29 13:36:28,744 - core.hygm.validation.memgraph_data_validator - INFO - Expected schema: 14 nodes, 20 relationships
2025-10-29 13:36:28,754 - core.hygm.validation.memgraph_data_validator - INFO - Used fallback query for relationship count
2025-10-29 13:36:28,754 - core.hygm.validation.memgraph_data_validator - INFO - Data counts from schema: 40806 nodes, 109051 rel
2025-10-29 13:36:28,754 - core.hygm.validation.memgraph_data_validator - INFO - ✅ Node count validation passed: 40806 nodes
2025-10-29 13:36:28,755 - core.hygm.validation.memgraph_data_validator - INFO - Validation Summary: Validation PASSED: No issues found
2025-10-29 13:36:28,755 - core.hygm.validation.memgraph_data_validator - INFO - Validation Score: 100/100
2025-10-29 13:36:28,755 - core.migration_agent - INFO - ✅ Post-migration validation PASSED
2025-10-29 13:36:28,755 - core.migration_agent - INFO - Validation score: 100/100
2025-10-29 13:36:28,764 - core.migration_agent - INFO - Stored migration metadata for localhost/sakila
============================================================
📊 MIGRATION RESULTS
============================================================
✅ Migration completed successfully!
📋 Tables processed: 0/14
✅ Post-migration Validation:
🎯 Status: PASSED
📊 Validation Score: 100/100
📁 Tables: 14/14
🏷️ Properties: 0/0
🔗 Relationships: 19/20
📇 Indexes: 39/39
🔒 Constraints: 14/14
✅ No validation issues found
🏁 Final status: Post-migration validation completed
============================================================Step 7: Review the Proposed Graph Model
For more control, you can run the agent in incremental mode to review and refine the model step-by-step:
uv run main.py --mode incrementalIf you are using incremental mode, SQL2Graph will propose node and edge types derived from your tables and relationships. You can review and modify these before ingestion:
- Rename node labels
- Drop unnecessary properties
- Adjust or remove constraints
This is your moment to fine-tune the graph structure.
Step 8: Accept and Ingest
Once you are satisfied, confirm the model. SQL2Graph will execute the generated Cypher queries and migrate your data into Memgraph with nodes, relationships, and constraints.
You will see validation reports confirming what was created, indexed, or skipped.
Step 9: Explore Your Graph in Memgraph Lab
Open Memgraph Lab and connect to your Cloud instance. Then, in the Graph Schema window, click Generate Schema (or Reload if a schema already exists).
You will now be able to visually explore how your SQL data connects and is represented as a graph schema inside Memgraph.
Best Practices
-
Validate Your Migration
After each migration, run SQL2Graph’s validation checks to confirm data integrity, constraint consistency, and schema accuracy. This step ensures that your graph matches the structure and logic of your source data.
-
Iterate and Improve
Refine your graph model as you go. SQL2Graph supports rerunning migrations, adjusting schema designs, or switching between deterministic and AI-powered strategies. Iteration helps you find the most meaningful representation of your data without starting from scratch.
-
Scale and Automate
Once your process is stable, integrate SQL2Graph into your ETL or data pipeline workflows. Automate migrations for regular syncs so your graph stays up to date as your data evolves.
Why SQL2Graph Matters
SQL2Graph is not just about migrating data. It is about making that data usable for context retrieval and AI workflows.
It simplifies the process of moving from SQL to graph so you can prepare your relational data for GraphRAG quickly, without changing your existing queries.
Read more:
Wrapping Up
Migrating from SQL to graph databases used to require custom scripts, manual mapping, and days of work. SQL2Graph changes that. With just a few steps, you can move your data from relational tables to knowledge graphs ready for context-aware retrieval.
It’s fast, scalable, and built for AI engineers who want to bring structure and meaning into their data workflows.
💡 Try it instantly in Memgraph Cloud
Skip local setup and start using SQL2Graph directly in Memgraph Cloud. Sign up, create a new project, and migrate to your instance in just a few minutes.
Alternatively, you can run Memgraph locally via Docker to see how quickly you can go from SQL to graph.