Welcome to SnapFlow - the lightning-fast database snapshot manager for modern development workflows!
SnapFlow is a tool that lets you:
- Create instant snapshots of your databases
- Restore databases in seconds (up to 140x faster than traditional methods)
- Switch between database states effortlessly
- Test migrations safely
- Experiment with data without fear
# Clone the repository
cd "C:\Users\USER\OneDrive\Music\st 1\snapflow"
# Install SnapFlow
pip install -e .
# Verify installation
python verify_snapflow.pyMake sure you have PostgreSQL or MySQL installed and running.
PostgreSQL Example:
# Make sure PostgreSQL is running
# Default: localhost:5432MySQL Example:
# Make sure MySQL is running
# Default: localhost:3306# Navigate to your project directory
cd C:\path\to\your\project
# Initialize SnapFlow (interactive wizard)
snapflow initThe wizard will ask for:
- Database URL (e.g.,
postgresql://localhost:5432/ormysql+pymysql://root@localhost/) - Database name to track (e.g.,
myproject_db) - Project name (defaults to database name)
# Create a snapshot called "baseline"
snapflow snapshot baseline# Make some changes to your database...
# (Add data, run migrations, etc.)
# Oops! Want to go back?
snapflow restore baseline
# Done! Your database is back to the baseline state# Create with auto-generated name (snap1, snap2, etc.)
snapflow snapshot
# Create with custom name
snapflow snapshot before-migration
# Create with description
snapflow snapshot test-data --description "Test dataset for feature X"# Show all snapshots for current project
snapflow listOutput example:
📸 Snapshots for project 'myproject':
✓ baseline
Created: 2 hours ago
Databases: 1
✓ before-migration
Created: 30 minutes ago
Description: Before adding user table
Databases: 1
# Restore latest snapshot
snapflow restore
# Restore specific snapshot
snapflow restore baseline
# Restore and wait for background copy
snapflow restore baseline --wait# Rename a snapshot
snapflow rename old-name new-name
# Replace a snapshot with current state
snapflow replace baseline
# Remove a snapshot
snapflow remove old-snapshot
# Clean up orphaned databases
snapflow gc# 1. Create snapshot before migration
snapflow snapshot before-users-table
# 2. Run your migration
python manage.py migrate # Django example
# or
alembic upgrade head # SQLAlchemy example
# 3. Test the migration
# ... run tests, check data ...
# 4a. If migration is good, keep it
snapflow snapshot after-users-table
# 4b. If migration failed, restore
snapflow restore before-users-table# On feature-branch-1
snapflow snapshot feature-1-data
# Switch to different branch
git checkout feature-branch-2
snapflow restore feature-2-data
# Back to feature-branch-1
git checkout feature-branch-1
snapflow restore feature-1-data# Save current state
snapflow snapshot clean-state
# Run risky SQL experiments
# ... experiment with queries ...
# Restore if something went wrong
snapflow restore clean-stateSnapFlow looks for snapflow.yaml in:
- Current directory
- Parent directories (up to filesystem root)
project_name: 'myproject'
tracked_databases: ['myproject_db', 'myproject_cache']
url: 'postgresql://localhost:5432/template1'
snapflow_url: 'postgresql://localhost:5432/snapflow_data'
logging: 20 # 10=DEBUG, 20=INFO, 30=WARNING, 40=ERRORYou can track multiple databases:
tracked_databases:
- 'main_db'
- 'analytics_db'
- 'cache_db'# Run comprehensive verification
python verify_snapflow.pyThis checks:
- ✅ Python version
- ✅ Module imports
- ✅ Dependencies
- ✅ Version detection
- ✅ CLI availability
- ✅ Model functionality
- ✅ Database operations
- ✅ Exception handling
# Run test suite
python run_tests.py
# Or use pytest directly
pytest -v
# With coverage report
pytest --cov=snapflow --cov-report=html
open htmlcov/index.htmlPros:
- ⚡ Lightning-fast template-based copying
- ✅ Native database rename support
- ✅ All features work perfectly
Requirements:
pip install psycopg2-binaryConnection String:
postgresql://user:password@localhost:5432/
Pros:
- ✅ All core features work
- ✅ Reliable table-by-table copying
Cons:
⚠️ Slower than PostgreSQL (table-by-table copy)⚠️ No native database rename (simulated)
Requirements:
pip install PyMySQLConnection String:
mysql+pymysql://root:password@localhost/
SnapFlow is designed for development environments, not production:
- Uses significant disk space (2x database size per snapshot)
- Assumes you have database creation permissions
- Not designed for critical data without backups
Each snapshot requires:
- Master copy: ~1x database size
- Slave copy: ~1x database size
- Total: ~2x database size per snapshot
Example: 1GB database with 3 snapshots = ~6GB storage
Your database user needs:
- CREATE DATABASE permission
- DROP DATABASE permission
- For PostgreSQL: CREATEDB role
Problem: User lacks database creation permissions
Solution (PostgreSQL):
ALTER USER myuser CREATEDB;Solution (MySQL):
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;Problem: PostgreSQL users need a database matching their username
Solution:
createdb $USERProblem: MySQL uses slower table-by-table copying
Solutions:
- Use PostgreSQL for better performance
- Use SSD storage
- Reduce database size during development
- Keep fewer snapshots
Problem: Background process failed or killed
Solution:
# Force inline copy
snapflow restore baseline --waitfrom snapflow import SnapFlow
# Use as context manager
with SnapFlow() as app:
# Create snapshot
snapshot = app.create_snapshot('test', description='Test snapshot')
# List all snapshots
snapshots = app.get_all_snapshots()
# Get specific snapshot
snapshot = app.get_snapshot('test')
# Restore
app.restore_snapshot(snapshot)
# Remove
app.remove_snapshot(snapshot)from snapflow import SnapFlow
def before_copy(database_name):
print(f"Copying {database_name}...")
app = SnapFlow()
app.create_snapshot('test', before_copy=before_copy)
app.close()- README: Full project documentation
- PROJECT_SUMMARY: Technical details
- COMPLETION_REPORT: Implementation details
- Examples: See
examples/directory
- GitHub Issues: Report bugs or request features
- GitHub Discussions: Ask questions, share tips
- Email: support@quantumdb.dev
# Show version
snapflow version
# Show help
snapflow --help
# Show command help
snapflow snapshot --helpYou now know how to:
- ✅ Install and verify SnapFlow
- ✅ Initialize configuration
- ✅ Create and restore snapshots
- ✅ Manage multiple snapshots
- ✅ Use SnapFlow in your workflow
- ✅ Troubleshoot common issues
Start snapshotting! 📸
snapflow snapshot baselineQuestions? Check the README or open an issue on GitHub.
Happy snapshotting! 🚀
SnapFlow v1.0.0 - Built with ❤️ by the QuantumDB Team