I am using mongoDB and am curious to whether you can import scripts like you can in MySQL:
mysql -uuser -ppassword database < script.sql
Can you do this with mongoDB?
Cheers
Eef
Execute a JavaScript file js script in a mongo shell that connects to the test database on the mongod instance accessible via the localhost interface on port 27017 . Alternately, you can specify the mongodb connection parameters inside of the javascript file using the Mongo() constructor.
MongoDB is a document-based NoSQL database that stores data in BSON (JSON-like) format. JavaScript is unanimously the most popular language for building web applications. It can also be used for building server-side applications usingNode. js.
A database object. Used to return another database without modifying the db variable in the shell environment.
You can pass a list of JS files to the mongo JavaScript shell and those will get executed:
$ echo "print('hello');" > test.js
$ ./mongo test.js
MongoDB shell version: 1.3.2-
url: test
connecting to: test
hello
You can use the normal mongo command line arguments if you need to specify a specific db, username, or password like you do in your above example.
I think you need to use a library like PyMongo to access the db, but after installing you should be able to script aggainst the mongoDB very well using python.
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