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?
Choose a file type and export location. Under Select Export File Type, select either JSON or CSV. If you select JSON, your data is exported to the target file as a comma-separated array. Then, under Output, choose where to export the file to.
You can export the structure and contents to a . sql file that can be read by just about anything. File > Export > Database to SQL file. Technically, the SQLite shell is not SQLite but a console application linked to SQLite which only is a library.
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 sqlitemongo
sqlitemongo <sqlitepath> <mongo uri> [<mongo database>]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With