Hi i am trying to store a text file into MongoDB but i got the error . "failing because no such method exists." % self.__name.split(".")[-1] TypeError: 'Collection' object is not callable. If you meant to call the 'insert' method on a 'Collection' object it is failing because no such method exists.
Can anyone please tell what is wrong here i also tried to do it with insert_one and insert_many but when i try to do it with insert_many it shows error raise TypeError("documents must be a non-empty list") TypeError: documents must be a non-empty list from pymongo import MongoClient client = MongoClient() db = client.test_database # use a database called "test_database" collection = db.files # and inside that DB, a collection called "files" f = open('hashes.txt') # open a file # build a document to be inserted text_file_doc = {"file_name": "hashes.txt"} # insert the contents into the "file" collection collection.insert(text_file_doc) File names Hshes.txt has follown=ing data Hash 1: 39331a6a2ea1cf31a5014b2a7c9e8dfad82df0b0666e81ce04cf8173cc5aed Hash 2: 0e0ff63b7e5e872b9ea2f0d604b5d5afd6ba05665e52246fa321ead5b79c00ad Hash 3: 89241ce841704508be1d0b76c478c9575ec8a7ec8be46742fd5acb0dc72787f3 Hash 4: 80283cb08f91b415aae04bcada0da1ca3e37bbe971ae821116b4d29008970bdb -- https://mail.python.org/mailman/listinfo/python-list