pymongo连接mongoDB报错
10.186.114.36:27017: timed out, Timeout: 30s, Topology Description: <TopologyDescription id: 64116407ee396f524c4f453b, topology_type: Single, servers: [<ServerDescription ('10.186.114.36', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('10.186.114.36:27017: timed out')>]>
感觉像是拒绝连接,但是pingi地址可以ping通。
语法应该没问题,测试过语法只是换了连接IP。
import pymongo
vin_list=[]
myclient = pymongo.MongoClient('mongodb://用户名:密码@IP:27017/mongo_telematics')
mydb = myclient["mongo_telematics"] # mysql的database
mycol = mydb["TP_VehicleRealtimeData"] # mysql的table
# result = mycol.find()
result = mycol.find({'terminalConnect': True,'ptReady':1})
for item in result:
print(item)
in_list.append(item['1'])
return in_list