Python Forum
Convert a mongo db scrip to python equivalent
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert a mongo db scrip to python equivalent
#1
Hi ,

I'm using below script in Robot mongo to update key value to and ObjectId type.
This is working perfectly

db.getCollection('tags').find({oid:{$not: {$type: 7}}}).forEach(function(x){
x.oid = ObjectId(x.oid);
db.getCollection('tags').save(x);
});

But I need to code same thing in python.
below python script get the collection I need to convert the objectId type but I'm not sure how to update it

db = client[db_name]
my_coll = db['tags']
Query={"oid":{"$not": {"$type": 7}}}
list1=my_coll.find(Query)
for x in list1:
pprint(x )




any support appreciated
Reply
#2
First of all which library do you use for MongoDB in your program?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Equivalent Python code from VBA Mishal0488 2 761 Apr-19-2024, 10:32 AM
Last Post: masonsbore
  Help creating shell scrip for python file marciokoko 10 1,363 Sep-16-2023, 09:46 PM
Last Post: snippsat
  Python C++ Template Equivalent deanhystad 7 3,389 May-04-2021, 07:45 PM
Last Post: deanhystad
  python mongo beginner2020 2 1,977 Oct-29-2020, 07:52 PM
Last Post: Larz60+
  Hi Guys, please help me to write SAS macro parameter equivalent code in Python Manohar9589 2 2,593 Jun-14-2020, 05:07 PM
Last Post: Larz60+
  python equivalent to MATLAB xcov chai0404 2 3,876 Apr-02-2020, 10:29 PM
Last Post: chai0404
  Python equivalent of Matlab code kwokmaster 1 3,451 Mar-25-2020, 10:14 PM
Last Post: j.crater
  Please Help , Total Noob need help to run Scrip on Windows ClicksCode 2 1,748 Mar-06-2020, 01:59 PM
Last Post: DeaD_EyE
  Equivalent of 'bwareafilt' for Python Mighty 1 3,596 Feb-05-2020, 10:32 PM
Last Post: Marbelous
  Boto 3 and Mongo DB zatlas1 2 2,954 May-23-2019, 07:32 PM
Last Post: zatlas1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020