I'm very new to Python. In my script I have written code to update MongoDB database.
def mongoInsert(userData, collection):
mconn = Connection(MONGODB_HOST,MONGODB_PORT)
mdb = mconn[MONGODB_DBNAME]
col = mdb[collection]
#The below codeis used to upsert the data in MongoDB.
for user in userData:
print user
col.update({'id': user[0]}, {'$set':user}, True)
return
where userData is a list,
userData = []
When I run the command python script_name.py using putty; the script runs without any error or exception. But when I see try to see the data in MongoDB, there is no data added in databse(I'm not sure, may be data has been added, but as I'm new here, I'm not able to see it). So I'm thinking now if there is any way to get the rows updated in database after the update command(any return type of update command e.g. boolean or integer), I will use it like
success = col.update({'id': user[0]}, {'$set':user}, True)
print success
but it always prints None value of success. So is there any way to check data is added or not, modifying the above code.