Intelligent SQL to NoSQL schema migration - analyzes query patterns to recommend optimal MongoDB schema design
Project description
Schema Travels
Schema Travels analyzes SQL database query patterns and recommends optimal NoSQL schema designs for MongoDB and DynamoDB migrations.
Features
- ๐ Query Pattern Analysis โ Parse PostgreSQL/MySQL logs to detect hot joins, access patterns, and read/write ratios
- ๐ค AI-Powered Recommendations โ Claude AI designs MongoDB schemas and reviews DynamoDB designs
- ๐๏ธ DynamoDB Single-Table Design โ Algorithmic clustering with Union-Find, automatic PK/SK patterns, GSI optimization
- ๐ Multiple Output Formats โ JSON, Terraform HCL, NoSQL Workbench
- ๐ SQL โ MongoDB Rewrites โ Automatic query rewrite examples
- ๐พ Caching โ Reproducible results with hash-based recommendation caching
- ๐ Migration Simulation โ Storage and latency impact estimation
Installation
pip install schema-travels
๐ Review of Schema by AI
So Please remember that Frontier Model Claude and its API key is required to use this tool.
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ ๏ธ API KEY NOT CONFIGURED โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Schema Travels requires an Anthropic API key for AI-powered โ
โ schema recommendations. โ
โ โ
โ Option 1: export ANTHROPIC_API_KEY=sk-ant-xxxxx โ
โ Option 2: echo "ANTHROPIC_API_KEY=sk-ant-xxxxx" > .env โ
โ โ
โ Get your API key at: https://console.anthropic.com/settings/keys โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
## Quick Start
### MongoDB Migration
```bash
export ANTHROPIC_API_KEY=sk-ant-...
schema-travels analyze \
--logs-dir ./postgresql_logs \
--schema-file ./schema.sql \
--target mongodb \
--output results.json
DynamoDB Migration
schema-travels analyze \
--logs-dir ./postgresql_logs \
--schema-file ./schema.sql \
--target dynamodb \
--dynamodb-output terraform \
--output results.json
How It Works
MongoDB Flow
Claude AI acts as architect โ analyzes your access patterns and designs the schema:
SQL Schema + Query Logs โ Pattern Analysis โ Claude AI โ EMBED/REFERENCE Decisions โ MongoDB Schema
DynamoDB Flow
Local algorithm designs, Claude AI reviews:
SQL Schema + Query Logs โ Pattern Analysis โ DynamoDB Designer โ Claude Review โ Final Design
โ
Union-Find clustering
PK/SK pattern generation
GSI candidate detection
CLI Options
schema-travels analyze [OPTIONS]
Options:
--logs-dir PATH Directory with query logs [required]
--schema-file PATH SQL schema file [required]
--target [mongodb|dynamodb] Target database [default: mongodb]
--output PATH Output file
# DynamoDB-specific
--dynamodb-mode [auto|single|multi] Design mode [default: auto]
--dynamodb-output [json|terraform|nosql_workbench] Output format
# AI control
--no-ai Skip AI (DynamoDB: algorithmic only)
--no-cache Bypass recommendation cache
--clear-cache Clear all cached results
--cache-mode [relaxed|strict] Cache sensitivity
# Filtering
--min-confidence FLOAT Filter by confidence threshold
--show-rewrites Show SQL โ MongoDB query rewrites
Example Output
MongoDB
{
"recommendations": [
{
"parent_table": "users",
"child_table": "addresses",
"decision": "embed",
"confidence": 0.92,
"reasoning": "High co-access (87%), bounded cardinality (<10 per user)"
}
],
"target_schema": {
"collections": [
{
"name": "users",
"embedded_documents": ["addresses"]
}
]
}
}
DynamoDB
{
"target_schema": {
"metadata": {
"design_mode": "single_table",
"confidence": 0.85,
"dynamodb_design": {
"table_name": "main_table",
"partition_key": "PK",
"sort_key": "SK",
"entities": [
{"name": "User", "pk_pattern": "USER#<id>", "sk_pattern": "PROFILE"},
{"name": "Order", "pk_pattern": "USER#<user_id>", "sk_pattern": "ORDER#<id>"}
],
"gsis": [
{"name": "GSI1", "pk_attribute": "email", "projection_type": "KEYS_ONLY"}
],
"ai_reviewed": true,
"ai_review_applied": true
}
}
}
}
Visualization
# Generate HTML visualization
python tools/visualize_schema.py \
--input results.json \
--output schema.html
open schema.html
Documentation
- ARCHITECTURE.md โ System design and data flows
- CHANGELOG.md โ Version history
- CONTRIBUTING.md โ Development guide
- TESTING_GUIDE.md โ Testing with real and synthetic data
- CLAUDE.md โ AI assistant context
Requirements
- Python 3.10+
- Anthropic API key (for AI recommendations)
License
MIT License โ see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file schema_travels-2.0.0.tar.gz.
File metadata
- Download URL: schema_travels-2.0.0.tar.gz
- Upload date:
- Size: 106.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56c5a8f69e46abcc6c4420bcc64ab6739920263fe81528d9582cee85d07e1493
|
|
| MD5 |
4ab5cb81ad7c4adc5fddc27579a6e2c0
|
|
| BLAKE2b-256 |
4451c342a029bc1fb5824a3bcb360b68a2016e671cf9ee5582802e0c4920d64f
|
File details
Details for the file schema_travels-2.0.0-py3-none-any.whl.
File metadata
- Download URL: schema_travels-2.0.0-py3-none-any.whl
- Upload date:
- Size: 93.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3c3e76f0c033401e8b576e72d5c2b0f8afe768df79a16ebfecea8ff5189b99c
|
|
| MD5 |
8b4eb41166733eb2d9ccbcba5e38d2a5
|
|
| BLAKE2b-256 |
74250abf31501dc038f5087aa858b80e2ce04ca2bb91ba0959d038bb355c78dd
|