简体   繁体   中英

Getting 'TypeError: 'str' object is not callable' for python script

When i run this below script, i am getting this error and not able to identify what is it? can someone help here?

Seeing error in line 14 as below

SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
test = db.profiles_data.count_documents({"createdOn": {"$lt": {"ISODate"("2020-12-01T12:00:00.000+0000")}}, "createdOn": {"$gte": {"ISODate"("2020-11-30T11:00:00.000+0000")}}})
TypeError: 'str' object is not callable

Code:

import pymongo
import json
from collections import namedtuple
import pandas as pd
import numpy as np


def getLogCount():

    uri = "mongodb connection string comes here"
    client = pymongo.MongoClient(uri)
    db = client.get_database('profile')

    test = db.profiles_data.count_documents({"createdOn": {"$lt": {"ISODate"("2020-12-01T12:00:00.000+0000")}}, "createdOn": {"$gte": {"ISODate"("2020-11-30T11:00:00.000+0000")}}})
    print("Test Count           : %d" %test)

LogCount = getLogCount()

"ISODate"("2020-12-01T12:00:00.000+0000")

should probably be

"ISODate": "2020-12-01T12:00:00.000+0000"

or possibly

"ISODate(2020-12-01T12:00:00.000+0000)"

(both places where ISODate appears)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM