Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use sqlite db with MeteorJS?

Tags:

sqlite

meteor

I'm creating a web app using meteorJS which will use the backup data from a third party app. This backed up data is in sqlite db format.

What is the best way to copy this sqlite db from dropbox and use it in meteorJS app.

So far I have tried to create a Java rest API which would parse this data and create a text file which meteors can use but I'm looking for a easier MeteorJS based solution if possible.

like image 385
user1880312 Avatar asked Oct 31 '22 11:10

user1880312


1 Answers

Here is a node.js package that can migrate sqlite to mongo:

https://github.com/davidyaha/sqlite-to-mongo

https://www.npmjs.com/package/sqlite-to-mongo

You should be able to use this to migrate the data to mongo and then use Meteor on top of that. I am not aware of any mainstream approaches to using sqlite with Meteor directly. Here would be an example on how to do the migration:

const SqliteToMongo = require('sqlite-to-mongo');

var importer = new SqliteToMongo('db.sqlite', 'mongodb://localhost/dbname');

importer.importCollection('users', {
  tableName : "USERS_TABLE",
  columns: {
    ID: '_id',
    USERNAME: 'username',
    EMAIL : 'profile.email'
  }
});

db.sqlite is going to be your sqlite database and mongodb://localhost/dbname will be your local mongo collection. If you are already running meteor, then that will be:

mongodb://localhost:27017/dbname

Where dbname is your database name. The second part is where you would migrate individual tables, where 'users' is the mongo collection (table) and USERS_TABLE is the sqlite table. The last bit is mapping the sqlite columns to fields in mongo.

like image 97
Brett McLain Avatar answered Nov 08 '22 14:11

Brett McLain