To import a large JSON dataset in MongoDB we have mongoimport utility which works like that:
mongoimport --host xxx.xxx.xxx.xxx --db destination-db -c tags < tmp/source-file.json
Is there a way to call 'mongoimport' using MongoID, the ruby Object-Document-Mapper for MongoDB ?
Thanks
Luca
Mongoid is effectively a wrapper around the Ruby driver. The Ruby driver should allow you to run any of the database commands.
However, mongoimport is not a command. mongoimport is a separate binary (or executable) file.
The only way to run mongoimport from Ruby is to "shell out". Typically this involves using some form of exec command. Here's the first search link for running shell commands from Ruby.
You can also parse the JSON from your file, and just run Model.create(json_obj) and Mode.save directly in a rake task.
Related
I need to test the model described in the IceNet paper but I am having issues making the Mamba environment.
After installing Mamba as described here, if I run the command mamba env create --name esports --file environment.yml I get the error The following arguments were not expected: environment.yml --file create Run with --help for more information.
Is there a way I can fix that? Also, I am working with an A100 GPU. Does it still make sense to use Mamba (the code was originally developed to run on a laptop) or am I already fine using Conda as usual?
Mamba should have the same API a Conda so the command yo tried should be correct. The error you get is likely due to a typo.
Note that I was able to trigger this exact error using Micromamba which has a different API than Mamba. Micromamba only has the micromamba create command that handles both YAML and list environment files. In that case, the correct command is:
micromamba create --name esports --file environment.yml
I have searched through related questions but have still not found an answer to this one.
I am using Wordmove to try and push/pull databases between local and live environments for WordPress (running on AMPPS on OSX). I have come back to trying the Wordmove method since the fork of WP-Sync-DB stopped working for me and appears to be abandoned now. This was the best free method for migrating databases between WordPress environments.
The error I am getting when running wordmove pull -e runcloud --db is sh: mysqldump: command not found
I am using Zsh and have already added a symlink to the only mysqldump I could locate on my system: alias mysqldump='/Applications/AMPPS/mysql/bin/mysqldump --host=localhost -uroot -proot' in .zprofile . It is also included in my .bash_profile . Without that line I simply get mysqldump not found (verified by commenting the line and needing to restart iTerm after each change).
So now if I type which mysqldump I get mysqldump: aliased to /Applications/AMPPS/mysql/bin/mysqldump --host=localhost -uroot -proot
But the error from Wordmove persists. I have enquired on the Wordmove Github and the author says this will be an error with how mysqldump if configured.
Disclaimer: I am not at all expert with CLI, only knowing enough to configure an environment for Gulp, using tools like Wordmove and basic stuff over SSH. I chose Zsh as it made a lot of stuff easier to use and to see, but any kind of configuration for this usually has me scratching my head!
Have I missed something obvious here? Perhaps the symlink is not set up correctly?
I see two conceptual problems here:
(1) You can not export an alias. An alias defined in the current Zsh, won't be automtaically be visible in a child Zsh.
(2) Your error message says
sh: mysqldump: command not found
which means that Zsh is not even involved when looking for mysqldump. This is a Posix shell script running.
Hence, every mechanism you want to use must work with Posix shell, which means that you need a program (a suitable shell script) named mysqldump in your PATH, which then calls the original mysqldump with the parameters you have in mind.
Make sure that the PATH is set up so that your private version of mysqldump is found before the one in /Applications/AMPPS/mysql/bin.
Im currently trying to import json data into elastic search.I have installed elastic search v2.2.1 in windows7 & trying to import json data into elasticsearch. But Im unable to import the same. I have checked various posts and they are specifying to execute the curl command. Below are the steps that I have tried
Tried to execute the below curl command via command prompt.But got a message that 'curl command is not recognised as an internal or external command'.
Installed cygwin and tried to execute the curl command, got a message'-bash: curl: command not found'.
I also tried to install sense chrome plugin, but unable to download the plugin and found that the plugin is no longer available.
I also installed the inquisitor plugin for elastic search, but looks like it helps to validate the query and does not help in importing the data into elastic search.
Any help on this is much appreciated.Thanks in advance.
For curl in windows you could try the download link here
The other way to use in windows is to use the Sense, which is a Kibana app. You can install it from here
The Sense app replaces the Chrome plugin
I am new to mongodb and trying to export a collection in json format. When I executed the query which I learnt query from the online manual I get an error.
Input:
mongoexport -d test -c Nick -o c:/results.json --journal
output:
error parsing command line options: --dbpath and related flags are not supported in 3.0 tools.
I am not sure how to interpret the output.
I am using mongodb 3.0.4 version. I am implementing the query in command line and not in the shell.
The --journal option is the one causing the problem as that option is removed from Mongo 3.0.0 (http://docs.mongodb.org/manual/reference/program/mongoexport/#options)
Remove the --journal option and it should work fine.
I think the --journal flag is not supported in 3.0 versions.
The query worked perfectly without the --journal option.
Thanks anyway.
How are the sql* commands meant to be used? They just output sql, so is there an elegant way to pass it to mysql? ./manage.py sqlindexes [app] gives me the mysql code - do I just note it down and then type it in? (edit: erm...copy and paste for others. heh.)
Pardon my ignorance, and please let me know if there's a completely different but better way of using it.
Pipe it to the dbshell command like so:
python manage.py sqlindexes my_app | python manage.py dbshell