Details
Description
When doing drop or find on a collection Python returns invalid BSON.
The collection has to be filled with a couple of entries.
The script in the end is an example.
Drop also returns the error but the connection is dropped.
There could be a problem with BSON,
the PHP driver also faults, see php issue https://jira.mongodb.org/browse/PHP-267.
I'm using mongodb from a Qnap server (version 1.8) https://github.com/skrabban/mongo-nonx86.
I haven't tested remote from python because the behavior is similar to the PHP issue mentioned.
-----------------------------------------------------------------
#!/usr/bin/python -w'
|
# -*- encoding: utf-8
|
|
import sys
|
if len(sys.argv)>1:
|
computer = sys.argv[1]
|
else:
|
computer = 'localhost'
|
|
from pymongo import Connection
|
collection = Connection(computer).test.test
|
|
collection.drop()
|
|
docs = [
|
{'nr':1},
|
{'dict':{'nr':1,'str':'2'},},
|
]
|
|
for d in docs:
|
collection.insert(d)
|
for o in collection.find(): print o
|
print "..."
|