How to create a new database and collection using pymongo?
Clash Royale CLAN TAG#URR8PPP
up vote
-2
down vote
favorite
I wanna create database and collection using python script so that I used pymongo driver. But i am unable to create database.
steps I followed.
from pymongo import MongoClient
con = MongoClient('localhost', 27017)
db = con.testdb
After this commands when i checked in mongoshell the db "testdb" is not created.
Can i use paramiko to interact with mongo shell ?
python version : 2.7
Answer would be appreciated.
windows database mongodb
add a comment |Â
up vote
-2
down vote
favorite
I wanna create database and collection using python script so that I used pymongo driver. But i am unable to create database.
steps I followed.
from pymongo import MongoClient
con = MongoClient('localhost', 27017)
db = con.testdb
After this commands when i checked in mongoshell the db "testdb" is not created.
Can i use paramiko to interact with mongo shell ?
python version : 2.7
Answer would be appreciated.
windows database mongodb
MongoDB creates new databases implicitly upon their first use, so you need to insert at least one document into a collection intestdb
in order to see the database created.
â Stennie
Apr 1 at 13:19
add a comment |Â
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I wanna create database and collection using python script so that I used pymongo driver. But i am unable to create database.
steps I followed.
from pymongo import MongoClient
con = MongoClient('localhost', 27017)
db = con.testdb
After this commands when i checked in mongoshell the db "testdb" is not created.
Can i use paramiko to interact with mongo shell ?
python version : 2.7
Answer would be appreciated.
windows database mongodb
I wanna create database and collection using python script so that I used pymongo driver. But i am unable to create database.
steps I followed.
from pymongo import MongoClient
con = MongoClient('localhost', 27017)
db = con.testdb
After this commands when i checked in mongoshell the db "testdb" is not created.
Can i use paramiko to interact with mongo shell ?
python version : 2.7
Answer would be appreciated.
windows database mongodb
asked Apr 1 at 6:25
Abdulvakaf K
294
294
MongoDB creates new databases implicitly upon their first use, so you need to insert at least one document into a collection intestdb
in order to see the database created.
â Stennie
Apr 1 at 13:19
add a comment |Â
MongoDB creates new databases implicitly upon their first use, so you need to insert at least one document into a collection intestdb
in order to see the database created.
â Stennie
Apr 1 at 13:19
MongoDB creates new databases implicitly upon their first use, so you need to insert at least one document into a collection in
testdb
in order to see the database created.â Stennie
Apr 1 at 13:19
MongoDB creates new databases implicitly upon their first use, so you need to insert at least one document into a collection in
testdb
in order to see the database created.â Stennie
Apr 1 at 13:19
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
From http://api.mongodb.com/python/current/tutorial.html
It states
An important note about collections (and databases) in MongoDB is that
they are created lazily - none of the above commands have actually
performed any operations on the MongoDB server. **Collections and
databases are created when the first document is inserted into them.**
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
From http://api.mongodb.com/python/current/tutorial.html
It states
An important note about collections (and databases) in MongoDB is that
they are created lazily - none of the above commands have actually
performed any operations on the MongoDB server. **Collections and
databases are created when the first document is inserted into them.**
add a comment |Â
up vote
0
down vote
accepted
From http://api.mongodb.com/python/current/tutorial.html
It states
An important note about collections (and databases) in MongoDB is that
they are created lazily - none of the above commands have actually
performed any operations on the MongoDB server. **Collections and
databases are created when the first document is inserted into them.**
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
From http://api.mongodb.com/python/current/tutorial.html
It states
An important note about collections (and databases) in MongoDB is that
they are created lazily - none of the above commands have actually
performed any operations on the MongoDB server. **Collections and
databases are created when the first document is inserted into them.**
From http://api.mongodb.com/python/current/tutorial.html
It states
An important note about collections (and databases) in MongoDB is that
they are created lazily - none of the above commands have actually
performed any operations on the MongoDB server. **Collections and
databases are created when the first document is inserted into them.**
answered Apr 2 at 8:38
Abdulvakaf K
294
294
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f434791%2fhow-to-create-a-new-database-and-collection-using-pymongo%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
MongoDB creates new databases implicitly upon their first use, so you need to insert at least one document into a collection in
testdb
in order to see the database created.â Stennie
Apr 1 at 13:19