TypeError: 'Collection' object is not callable

426 views
Skip to first unread message

nan gib

unread,
Jul 23, 2019, 4:54:51 AM7/23/19
to mongodb-user
 I am using PyMongo version 3.8 on python to try and connect to a MongoDB. I am running into a "TypeError: 'Collection' object is not callable. If you meant to call the 'get' method on a 'Collection' object it is failing because no such method exists." The code that is causing the problem is 
# query db after update
docs = collection.get()
for doc in docs:
print(u'{} => {}'.format(doc.id, doc.to_dict()))
I know that collection.get() is not able to be used for MongoDB. Could someone please help me find what the code is supposed to be to allow me to query the DB after the update that took place earlier on in the program. 

Summary of the program, I search my ports for an Arduino, when found I connect to it and it connects to a device that sends information back to update the DB.

Much thanks,
Nan Gib

nan gib

unread,
Jul 23, 2019, 7:49:12 AM7/23/19
to mongodb-user
I am also getting an exit code -1. What does this mean and how would I fix it?

nan gib

unread,
Jul 23, 2019, 8:14:04 AM7/23/19
to mongodb-user
# query db after update
docs = collection.find({})

for doc in docs:
print(u'{} => {}'.format(doc.id, doc.to_dict()))
I updated the code to this but it still is not running as it should be.

nan gib

unread,
Jul 23, 2019, 8:16:15 AM7/23/19
to mongodb-user
And it is not updating the database, even though my MongoDB database is connected. It is only connecting to the database and then update the info in the python console, but not the database document

Robert Cochran

unread,
Jul 23, 2019, 7:09:01 PM7/23/19
to mongodb-user
Hi,

I'm a casual user of Arduino compatible devices, including those which use the latest generation of microcontrollers like the Atmel SAMD platform. You have not posted enough information here for anyone to understand the problem you are having. You need to provide:

* The exact source code you are trying to run;
* 2 or 3 example documents;
* The full stack trace you are getting.

Without the above, it will be very difficult for anyone to really help you. Some might offer guesses -- but won't be able to reproduce your issue without the source code, example documents, and stack trace.

The screen shots you are posting are extremely hard to read. Can you please post actual text inside <code> tags?

I would be curious to have a description of how exactly you are using the Arduino device. What device exactly are you using? 

Are you attempting to use MicroPython or Adafruit.com's CircuitPython? Those only work on certain hardware devices and I do not believe there is a supported MongoDB driver for those languages.

An Arduino device by itself cannot directly connect to an external database through software. Most use cases for an Arduino are to have it collect sensor data, which is then captured by another device as text information, and which is then reformatted on the capturing device and added to a database in an independent process from the Arduino. So it is important to describe how you are using an Arduino here -- unless, of course, there is no actual flow of data from an Arduino to MongoDB in your use case. 


Please understand that I am not an employee of MongoDB, Inc. I'm just another user attempting to help you.

Thanks so much

Bob
Reply all
Reply to author
Forward
0 new messages