Converts a Table from a Mysql Server into an MongoDB Collection.
Steps:
- Connects to both Servers (Mysql and MongoDB)
- Reads Table-Details
- Uses Table-Details to create the Collection with Validator (required Fields and Datatypes)
- Reads Rows in Bulk from Mysql Table
- Inserts Documents in Bulk to MongoDB Collection
- Python 3
- pip installed
The following CLI-Arguments are available
-h, --help show this help message and exit
--mysqlHost MYSQLHOST
Mysql(Source) Hostname or IP
--mysqlUser MYSQLUSER
Mysql(Source) Usernmae
--mysqlPassword MYSQLPASSWORD
Mysql(Source) Password
--mysqlDatabase MYSQLDATABASE
Mysql(Source) Database
--mysqlTable MYSQLTABLE
Mysql(Source) Table
--mongoHost MONGOHOST
MongoDB(Dest) Hostname or IP
--mongoUser MONGOUSER
MongoDB(Dest) Username
--mongoPassword MONGOPASSWORD
MongoDB(Dest) Password
--mongoDatabase MONGODATABASE
MongoDB(Dest) Database
--mongoCollection MONGOCOLLECTION
MongoDB(Dest) Collection
--selectlimit SELECTLIMIT
Rows to select at once (Tweak for best Performance) Default: 100
- Copy the
config.example.ini
File toconfig.ini
- Change the Variables to your needs
pip install -r requirements.txt
python3 mysql2mongodb.py # using config.ini File
# < OR >
python3 mysql2mongodb.py --mysqlHost 127.0.0.1 --mysqlUser user --mysqlPassword pw --mysqlDatabase test --mysqlTable table --mongoHost 127.0.0.1 --mongoUser user --mongoPassword pw --mongoDatabase test --mongoCollection collection