{"id":16514151,"url":"https://github.com/altafjava/migrate-mongodb-to-mysql","last_synced_at":"2025-06-15T17:32:52.472Z","repository":{"id":219610346,"uuid":"749453464","full_name":"altafjava/migrate-mongodb-to-mysql","owner":"altafjava","description":"This Python script migrates data from a MongoDB database to a MySQL database. It iterates over all collections in the MongoDB database, creates corresponding tables in the MySQL database, and inserts the data.","archived":false,"fork":false,"pushed_at":"2024-02-18T10:39:58.000Z","size":22,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T17:32:03.938Z","etag":null,"topics":["database","database-migration","migrate","migrate-database","migrate-mongodb-to-mysql","migration","mongodb","mongodb-migration","mongodb-mysql","mongodb-to-mysql","mysql","python","sql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/altafjava.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-28T16:25:09.000Z","updated_at":"2024-10-09T18:13:04.000Z","dependencies_parsed_at":"2024-02-03T08:22:41.512Z","dependency_job_id":"09c96cc4-4ec5-4c97-9b98-58d586d5e0b2","html_url":"https://github.com/altafjava/migrate-mongodb-to-mysql","commit_stats":null,"previous_names":["altafjava/migrate-mongodb-to-mysql"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/altafjava/migrate-mongodb-to-mysql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altafjava%2Fmigrate-mongodb-to-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altafjava%2Fmigrate-mongodb-to-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altafjava%2Fmigrate-mongodb-to-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altafjava%2Fmigrate-mongodb-to-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/altafjava","download_url":"https://codeload.github.com/altafjava/migrate-mongodb-to-mysql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altafjava%2Fmigrate-mongodb-to-mysql/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260022437,"owners_count":22947159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","database-migration","migrate","migrate-database","migrate-mongodb-to-mysql","migration","mongodb","mongodb-migration","mongodb-mysql","mongodb-to-mysql","mysql","python","sql"],"created_at":"2024-10-11T16:11:37.007Z","updated_at":"2025-06-15T17:32:52.410Z","avatar_url":"https://github.com/altafjava.png","language":"Python","readme":"# MongoDB to MySQL Migration Script\n\nThis Python script migrates data from a MongoDB database to a MySQL database. It iterates over all collections in the MongoDB database, creates corresponding tables in the MySQL database, and inserts the data.\n\n## Prerequisites\n\nEnsure that you have Python installed on your machine. You also need to have MongoDB and MySQL servers running.\n\n## Installation\n\n1. Clone the repository to your local machine.\n2. Navigate to the project directory.\n3. Install the required Python packages:\n\n    ```bash\n    pip install pymongo\n    pip install pymysql\n    ```\n\n## Configuration\n\nUpdate the MongoDB and MySQL database credentials in the `config.py` file:\n\n```python\n# Source Database Configuration\nmongo_config = {\n    'url': 'mongodb://localhost:27017/',\n    'db_name': 'sample_guides',\n}\n\n# Destination Database Configuration\nmysql_config = {\n    'host': 'localhost',\n    'user': 'root',\n    'password': 'mysql',\n}\n\nmysql_db_name = 'Test_DB-MySQL' # This will be converted to snake case(test_db_mysql)\n```\n\n## Usage\nRun the script with the following command:\n```bash\npython migrate.py\n```\nThe script will connect to the MongoDB database, iterate over all collections, It then connects to the MySQL server, **drops the existing database if it exists**, and creates a new one. For each MongoDB collection, the script creates a corresponding table and column with **snake_case** names based on the MongoDB collections' structure, and insert data accordingly. It skips the `_id` and `_class` columns during table creation and data insertion based on the configuration settings `SKIP_ID_FIELD` and `SKIP_CLASS_FIELD` respectively.\n\n## Note\nThis script assumes that the MongoDB and MySQL servers are running on localhost. If your servers are running on different hosts, update the host information in the database credentials.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltafjava%2Fmigrate-mongodb-to-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faltafjava%2Fmigrate-mongodb-to-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltafjava%2Fmigrate-mongodb-to-mysql/lists"}