Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7692497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:51:58+00:00 2026-05-31T20:51:58+00:00

I have code in Python/PyMongo like ( code should simulate inner join and all

  • 0

I have code in Python/PyMongo like ( code should simulate inner join and all documents from second collection to put (nest inside) in list and add to first appropriate document in Mongo). Idea is to load two collections and pass two fields ( name of fields for connection ) and all documents from second collection with same attribute like in first put in list and add to appropriate document in first collection .

(For example in first collection I have documents with fileds “country”,”population” and in second I have “country” and “car factories” and I want to put ( denormalize ) first collection list of all factories for appropriate country)

    for f in first_collection_records:
        temp=[]
        id=f['_id']
        second_collection_records.rewind()
        for s in second_collection_records:
            if f[field_one]==s[field_two]:
                temp.append(s)
        f[self.__second_collection_name__]=temp
        first_collection_records.update({"_id":id}, f, safe=True)

but I got error ‘Cursor’ object has no attribute ‘update’. What I done wrong ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:51:59+00:00Added an answer on May 31, 2026 at 8:51 pm

    first_collection_records is a pymongo.cursor.Cursor object. It’s the result you get when you call db.first_collection.find(). You need to call update on your original collection object:

    # assuming your query looked something like this
    first_collection_records = db.first_collection.find()
    
    # your code here....
    
    # your last line should reference the collection object to do the update
    db.first_collection.update({"_id":id}, f, safe=True)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got python code running on multiple analyzer machines each picking documents from
I have python code something like: from string import Template import optparse def main():
I currently have some code in Python where I have entered the values from
I have some python code that looks like this: return [x.doSomething() for x in
I have a python code something like this file_out.write(str(i).strip()+\t+str(dict1[i]).strip()+\n) But when i try to
I have Python code that pulls info from a sqlite database and then write
I have python code with C libraries, I use SWIG to plug it all
I have some code in python, that bitwise or-equals b to all the values
I have this Python code to do this: from struct import pack as _pack
I have written a code in Python to create a transition probability matrix from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.