Create temporary MongoDB Docker container (named some-mongo
) and fill it with JSON data from data
subdir in current working directory. The documents are placed in tmp
DB, tmp
collection.
Last active
September 3, 2019 10:55
-
-
Save tomasbedrich/9eeefd280bbf00473569886e25399ad6 to your computer and use it in GitHub Desktop.
MongoDB Docker JSON analysis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -p 27017:27017 -v $(pwd)/data:/import --name some-mongo -d mongo | |
docker exec -ti some-mongo bash -c "for f in /import/*; do mongoimport --jsonArray --db tmp --collection tmp --file \$f; done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
client = MongoClient() | |
db = client.tmp | |
print(db.tmp.find_one()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment