'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).

  1. You just need to select collection
  2. Select file to import
  3. You can also unselect data which is going to import. Also many options are there.
  4. Collection imported

See how to import video

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

  1. sudo npm install --global sqlitemongo

  2. sqlitemongo <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