'Export database from SQLite to MongoDB
What's probably the easiest way to migrate a small (< 10MB) database from SQLite to MongoDB using command line interfaces?
From what I've figured out so far it seems I'll have to do table-by-table:
> .output user.csv
> .mode csv
> .header on
> select*from user;
> .quit
> mongoimport --collection user --type csv --headerline --db rebuild user.csv
I've also done this before with a script that traversed an XML dump of an RDBMS and populated the NoSQL DB.
Both of these methods work, but they feel inelegant - surely, there's a better way to do it?
Solution 1:[1]
You can easily import sqlite CSV elegantly with 3T MongoChef Tool (3.2+ version).
- You just need to select collection
- Select file to import
- You can also unselect data which is going to import. Also many options are there.
- Collection imported
Solution 2:[2]
If you can use NPM and node, there's an open-source tool called sqlitemongo that handles this use-case for you in a CLI interface.
Run the following terminal commands
sudo npm install --global sqlitemongosqlitemongo <sqlitepath> <mongo uri> [<mongo database>]
Solution 3:[3]
Export the data using SqlLiteBrowser and import that using MongoDB Compass
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Somnath Muluk |
| Solution 2 | |
| Solution 3 | Moumit |
