Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import data into openshift mongoDb

I created a java application on openshift with the mongoDb cartridge. My application runs fine, both locally on jboss AS7 as on openshift. So far so good. Now I would like to import an csv into the mongoDb on the openshift cloud. The command is fairly simple:

mongoimport -d dbName -c collectionName --type csv data.csv --headerline

This works fine locally, and I know how to connect to the openshift-shell and remote mongo-db. But my question is: how can I use a locally stored file (data.csv) when executing this commando in a ssh-shell.

I found this on the openshift forum, but I don't realy know what this tmp directory is and how to use it. I work on windows, so I use Cygwin as a shell-substitute.

Thanks for any help

like image 336
thomash Avatar asked Mar 18 '12 21:03

thomash


1 Answers

The tmp directory is shorthand for /tmp. On Linux, it's a directory that is cleaned out whenever you restart the computer, so it's a good place for temporary files.

So, you could do something like:

$ rsync data.csv openshiftUsername@openshiftHostname:/tmp
$ ssh openshiftUsername@openshiftHostname
$ mongoimport -d dbName -c collectionName --type csv /tmp/data.csv --headerline
like image 181
kristina Avatar answered Nov 11 '22 01:11

kristina