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

python script to connect to mongodb master
flask-admin and pymongo search
Running code when mongoengine loads a document
Can't replace mongo document
How do I call a function with pymongo using webpy?
python motor offers fetch_next exception on aggregation
python motor mongo cursor length or peek next
PyMongo check if update succeeded
insert and query an OrderedDict in MongoHQ
Return .str of ObjectID using pymongo
Selecting the lowest/highest with find_one in Pymongo
Safe use of Pymongo's find_one
Pymongo $in + $regex
How can I get pymongo to always return str and not unicode?
SON Manipulator in mongo queries
How to append a document to a 2nd level embedded model list document in Django and mongoengine

Categories

HOME
ionic2
webview
generics
activemq
histogram
openflow
supercollider
mutation-testing
log4j2
createjs
bundler
texas-instruments
uima
checkout
uislider
amazon-sns
perfino
react-dnd
mod-wsgi
tortoisemerge
riotjs
shapeless
kendo-listview
nest
iscroll
task-parallel-library
windows-store
imgur
jacoco-maven-plugin
hypothesis-test
sony-future-lab-n
nonlinear-functions
head.js
comm
google-news
android-mediarecorder
palindrome
dex
gawk
ogg
portal
scheduledexecutorservice
java-2d
logical
nsrunloop
svnserve
wininet
cdo.message
android-4.2-jelly-bean
apache-pig-grunt
gwt-syncproxy
webgrind
google-maps-api-2
dsa
srv-record
blockquote
unidata
quercus
subfolder
subview
datagridcomboboxcolumn
rpg
git-reset
screwturn
forio-contour
redpitaya
refit
air-native-extension
profiles
iosched
proxy-server
insertonsubmit
stty
form-for
jacob
aero
proc-open
spark-view-engine
playorm
live-wallpaper
struts2-s2hibernate
liveconnect
fitch-proofs
nsfont
acpi
django-apps
groovy-console
sql-parametrized-query
3des
django-pagination
explicit
principles
jquery-effects
tacit-programming
rakudo

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App