pymongo


pymongo query return in direct query not in pymongo


Description
I want to understand the error on my query because when I use the robomongo I get the results from the mongodb, but when I use pymongo there is no result.
I'm using pymongo and robomongo.
Query on mongodb directly using robomongo:
db.getCollection('security').find({"EventData.Data": {"#Name" :
"TargetUserName","#text" : "domain.admin"}})
{
"_id" : ObjectId("57fd772b6ee6dd16b32fb6b5"),
"#xmlns" : "http://schemas.microsoft.com/win/2004/08/events/event",
"System" : {
"Provider" : {
"#Name" : "Microsoft-Windows-Security-Auditing",
"#Guid" : "{54849625-5478-4994-a5ba-3e3b0328c30d}"
},
"EventID" : {
"#Qualifiers" : "",
"#text" : "4634"
},
"Version" : "0",
"Level" : "0",
"Task" : "12545",
"Opcode" : "0",
"Keywords" : "0x80200000000000",
"TimeCreated" : {
"#SystemTime" : "2011-08-25 12:47:24.765669"
},
"EventRecordID" : "227103",
"Correlation" : {
"#ActivityID" : "",
"#RelatedActivityID" : ""
},
"Execution" : {
"#ProcessID" : "688",
"#ThreadID" : "3160"
},
"Channel" : "Security",
"Computer" : "TEST.domain.local",
"Security" : {
"#UserID" : ""
}
},
"EventData" : {
"Data" : [
{
"#Name" : "TargetUserSid",
"#text" : "S-1-5-21-111122115-1035525444-682003330-10164"
},
{
"#Name" : "TargetUserName",
"#text" : "domain.admin"
},
{
"#Name" : "TargetDomainName",
"#text" : "TEST"
},
{
"#Name" : "TargetLogonId",
"#text" : "0x0000000018be99"
},
{
"#Name" : "LogonType",
"#text" : "7"
}
]
}
}
The query using pymongo:
from pymongo import MongoClient
client = MongoClient()
db = client['test-db']
collection = db.security
print collection.find_one({"EventData.Data": {"#Name" : "TargetUserName","#text" : "domain.admin"}})
The result from this is:
➜ python get_records.py
None

Related Links

Spark Streaming: foreachRDD insert into mongoDB using python?
how to find right version of bson from pip for pymongo/mongoengine
How to enable `projection` in pymongo query class `find()`?
Variables don't hold value for very long pymongo ipython
pymongo upgrade to 3.0.3 causes this statement to fail
UUID to NUUID in Python
how to test for empty mongodb query in pymong
read video file from mongodb with pymongo
Get OperationFailure error with PyMongo 2.7.1
Inserting string as regular string in mongodb
Mongos + Pymongo 2.5 ==>No suitable hosts found
pymongo collection add item using update
How to convert objectid to string
Conditional atomic mongo remove with different results
python script to connect to mongodb master
flask-admin and pymongo search

Categories

HOME
hpoo
user-interface
firebase
apple-push-notifications
dotnetnuke
selenium-builder
haproxy
android-emulator
twitter-fabric
linker
share
angular-meteor
gprs
msmq
orc
xbap
xbox360
pygobject
scala-ide
psql
android-permissions
dashdb
sap-lumira
tf-idf
ccavenue
tsung
audit
source-insight
vcenter
epplus
knights-tour
private-key
microsoft-certifications
om-next
ms-media-foundation
bean-validation
wdk
installanywhere
django-crispy-forms
ms-dos
suds
vungle-ads
spooler
notesview
gcal
portability
connect-direct
email-forwarding
sesame
cognos-tm1
okio
ndk-build
fuzzer
wininet
gcloud-node
conan
dojo-build
simian
android-async-http
gridbaglayout
teensy
stack-smash
bjam
pythonxy
vdm-sl
artisan
ampersand
wicked-gem
deque
password-recovery
xhprof
coding-efficiency
eclim
vlab
notifyjs
jquery-transit
virtual-channel
postgres-xc
examine
significant-digits
ckeditor.net
tridion-2011
cgrectmake
onconfigurationchanged
popup-blocker
hardcode
navigationcontroller
dynamic-c
filelock
firefly-mv
page-curl
regression-testing
firephp
version-control-migration
downloadfile
account-management
parentid

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App