Inserting data from Python into MongoDB via Pymongo

448 views
Skip to first unread message

Yaroslav Kyrpych

unread,
Dec 30, 2013, 12:41:17 AM12/30/13
to mongod...@googlegroups.com
Hello,

I am collecting data in the str type from html. Do I need to serialize data using json module in Python before inserting data into Mongo? Related question, do I need to insert dictionary from Python or dictionary can be created in mongo?

Thank you in advance!

Yaroslav

Asya Kamsky

unread,
Dec 30, 2013, 1:52:38 AM12/30/13
to mongodb-user
Have you looked at any of the examples in tutorial in pymongo documentation?   I think it's pretty straight forward and if they don't answer your questions you can come back here and ask about specific operations...  You do not need to use json module - if the data is in a dictionary you can just pass that to pymongo insert method.

Asya



--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
 
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Yaroslav Kyrpych

unread,
Dec 30, 2013, 2:39:55 PM12/30/13
to mongod...@googlegroups.com
Yes, I did. However, the reason I was/am confused is that when I try to create a dictionary in Python (3.3) by adding string (~1.8MB in size), the IDLE crashes. I was confused by this behavior as I could not find anywhere that there is a limitation on size of "value" in key:value pair in Python. The smaller size addition does work though. It's probably not quite Mongo question, just thoughts in case I miss anything...

Asya Kamsky

unread,
Dec 30, 2013, 6:52:48 PM12/30/13
to mongodb-user
Might you be running out of memory on the client (i.e. IDLE crashing for out-of-memory)?

Asya

Aliane Abdelouahab

unread,
Dec 30, 2013, 8:58:15 PM12/30/13
to mongod...@googlegroups.com
have you tried adding it directly from the console or ipython for example?

2013/12/31 Asya Kamsky <as...@mongodb.com>:

Yaroslav Kyrpych

unread,
Jan 1, 2014, 1:59:45 PM1/1/14
to mongod...@googlegroups.com, alabde...@gmail.com
I just tried to run it out of console and I am getting error message as follows:
"python is not recognized as an internal or external command, operable program or batch file"

Python is installed in C:\Python33 directory. I could not start python from my personal directory (C:\Users\MyName> python). 

It seems when I try to run python, windows can not route command to the location where python is installed. 

Any help is highly appreciated!

Yaroslav Kyrpych

unread,
Jan 1, 2014, 3:56:54 PM1/1/14
to mongod...@googlegroups.com, Aliane Abdelouahab
I just tried directly from console - it seems to work, although I can see only the end of the entire string as the beginning got cut off. It's much more convenient for me to work from IDLE though. Any suggestions what can be done? Thank you.

Alan Spencer

unread,
Jan 6, 2014, 9:46:05 AM1/6/14
to mongod...@googlegroups.com, Aliane Abdelouahab
Not sure this will help, but you may want to try an alternative to IDLE, if an IDE is what you need: http://www.jetbrains.com/pycharm/
Reply all
Reply to author
Forward
0 new messages