Port your RethinkDB data to MySQL
Project description
RethinkPort 🚢
A comprehensive tool for migrating RethinkDB databases to MySQL, designed to work with official RethinkDB dump files.
Port your RethinkDB data to MySQL.
Overview
This tool was created to address the lack of reliable migration tools for moving from RethinkDB to MySQL. It handles the complete migration pipeline including:
- Schema inference and optimization
- Data type conversion (including RethinkDB-specific types)
- Index and constraint migration
- Foreign key dependency management
- Batch processing for large datasets
Features
- ✅ Official RethinkDB dump support - Works with
rethinkdb dumpoutput - ✅ Smart schema inference - Analyzes data to create optimal MySQL schemas
- ✅ Data type conversion - Handles RethinkDB TIME objects, JSON, arrays
- ✅ Index migration - Preserves indexes and primary keys from .info files
- ✅ Dependency management - Processes tables in correct order for foreign keys
- ✅ Batch processing - Efficient handling of large datasets
- ✅ Progress tracking - Real-time migration statistics
- ✅ Error handling - Comprehensive logging and error reporting
Installation
Prerequisites
- Python 3.9+
- MySQL 5.7+ or MariaDB 10.2+
- RethinkDB (for creating dumps)
Install from PyPI
pip install rethinkport
Install from Source
git clone https://github.com/aoamusat/rethinkport.git
cd rethinkport
pip install -e .
Usage
Step 1: Create RethinkDB Dump
First, create a dump of your RethinkDB database:
rethinkdb dump -c <host:port> -f my_database_dump.tar.gz
Step 2: Extract the Dump
tar -xzf my_database_dump.tar.gz
This creates a directory structure like:
rethinkdb_dump_<date>/
└── <database_name>/
├── Table1.info
├── Table1.json
├── Table2.info
├── Table2.json
└── ...
Step 3: Run the Migration
Basic Usage
rethinkport /path/to/rethinkdb_dump_<date>/<database_name>/
With Configuration File
rethinkport /path/to/dump/ --config config.json
Command Line Options
rethinkport --help
usage: rethinkport [-h] [--config CONFIG] [--host HOST] [--port PORT]
[--user USER] [--password PASSWORD] [--database DATABASE]
[--dry-run] [--batch-size BATCH_SIZE] [--table-order TABLE_ORDER]
dump_path
RethinkPort 🚢 - Port your RethinkDB data to MySQL
positional arguments:
dump_path Path to extracted RethinkDB dump directory
optional arguments:
-h, --help show this help message and exit
--config CONFIG Configuration file path
--host HOST MySQL host (default: localhost)
--port PORT MySQL port (default: 3306)
--user USER MySQL username (default: root)
--password PASSWORD MySQL password
--database DATABASE MySQL database name
--dry-run Show what would be migrated without executing
--batch-size BATCH_SIZE
Batch size for data insertion (default: 1000)
--table-order TABLE_ORDER
Custom table processing order (JSON file)
Configuration
Environment Variables
export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=root
export MYSQL_PASSWORD=your_password
export MYSQL_DATABASE=your_database
Configuration File
Create a config.json file:
{
"mysql": {
"host": "localhost",
"port": 3306,
"user": "root",
"password": "your_password",
"database": "your_database",
"charset": "utf8mb4"
},
"migration": {
"batch_size": 1000,
"table_order": [
"Users",
"Products",
"Orders"
]
}
}
Data Type Mapping
| RethinkDB Type | MySQL Type | Notes |
|---|---|---|
| String (short) | VARCHAR(255) | Auto-sized based on data |
| String (long) | TEXT | For strings > 2000 chars |
| Number (int) | INT/BIGINT | Based on value range |
| Number (float) | DECIMAL(15,4) | Preserves precision |
| Boolean | BOOLEAN | Direct mapping |
| Object | JSON | RethinkDB objects → MySQL JSON |
| Array | JSON | RethinkDB arrays → MySQL JSON |
| TIME | DATETIME | Converts epoch_time to MySQL datetime |
| UUID | VARCHAR(255) | For primary/foreign keys |
Examples
Basic Migration
# Dump RethinkDB
rethinkdb dump -c localhost:28015 -f myapp_dump.tar.gz
# Extract
tar -xzf myapp_dump.tar.gz
# Migrate
rethinkport rethinkdb_dump_2024_01_15/myapp/
Advanced Migration with Custom Configuration
rethinkport \
rethinkdb_dump_2024_01_15/myapp/ \
--config production_config.json \
--batch-size 5000 \
--dry-run
Troubleshooting
Common Issues
-
Connection Errors
Error: Failed to connect to MySQL- Check MySQL credentials and connection
- Ensure MySQL server is running
- Verify database exists
-
Large Dataset Timeouts
Error: MySQL server has gone away- Increase
max_allowed_packetin MySQL - Reduce
--batch-size - Check MySQL timeout settings
- Increase
-
Schema Conflicts
Error: Table already exists- Tool drops existing tables by default
- Check MySQL user permissions
- Verify database name
Performance Tips
- Use SSD storage for better I/O performance
- Increase MySQL
innodb_buffer_pool_size - Adjust
--batch-sizebased on available memory - Run migration during low-traffic periods
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Setup
git clone https://github.com/aoamusat/rethinkport.git
cd rethinkport
pip install -e ".[dev]"
pytest
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built to solve real-world RethinkDB migration challenges
- Inspired by the need for reliable database migration tools
- Thanks to the RethinkDB and MySQL communities
Support
If you encounter issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Include your RethinkDB/MySQL versions and error logs
Note: This tool was created because existing migration solutions were insufficient for complex RethinkDB to MySQL migrations. It's designed to handle real-world scenarios with large datasets, complex schemas, and foreign key relationships.
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 rethinkport-1.0.3.tar.gz.
File metadata
- Download URL: rethinkport-1.0.3.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa4a61ddef1bcecb0534d07acf0b223dfc59decb812b6bcd53d04cb8fb905044
|
|
| MD5 |
5fc9f54dff2a3abf81bbaf7233be03fc
|
|
| BLAKE2b-256 |
b2bdc5e3863432d9e771abfdfaf6deb12b1da7b8db251d39df8cdce9dc11530c
|
Provenance
The following attestation bundles were made for rethinkport-1.0.3.tar.gz:
Publisher:
publish.yml on aoamusat/rethinkport
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rethinkport-1.0.3.tar.gz -
Subject digest:
fa4a61ddef1bcecb0534d07acf0b223dfc59decb812b6bcd53d04cb8fb905044 - Sigstore transparency entry: 319657777
- Sigstore integration time:
-
Permalink:
aoamusat/rethinkport@57aa43c144a6752ae0935a5a48140c3809811d53 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/aoamusat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@57aa43c144a6752ae0935a5a48140c3809811d53 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rethinkport-1.0.3-py3-none-any.whl.
File metadata
- Download URL: rethinkport-1.0.3-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34b881b376381ea1bea2027e3db78245ec469c2b5ad2b0e93ef5c80cb496bad5
|
|
| MD5 |
5aefc99132ed5854beb720b06f9f7f19
|
|
| BLAKE2b-256 |
b4691617fd0c92bb2a1d7cd44fe8b746d8b4909f827b9506b490304f3b6c322a
|
Provenance
The following attestation bundles were made for rethinkport-1.0.3-py3-none-any.whl:
Publisher:
publish.yml on aoamusat/rethinkport
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rethinkport-1.0.3-py3-none-any.whl -
Subject digest:
34b881b376381ea1bea2027e3db78245ec469c2b5ad2b0e93ef5c80cb496bad5 - Sigstore transparency entry: 319657800
- Sigstore integration time:
-
Permalink:
aoamusat/rethinkport@57aa43c144a6752ae0935a5a48140c3809811d53 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/aoamusat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@57aa43c144a6752ae0935a5a48140c3809811d53 -
Trigger Event:
push
-
Statement type: