pymongo

from fangjia import mongoClients as mongoClients
import time
import pandas

def get_collection(db, name, host="192.168.0.136", port=27017):
    return mongoClients.MongoClients(db, name, host, port).collection

def findHouse(query, fields=None):

        seawater105 = get_collection("fangjia", "seawater", "192.168.0.105", 27777)    
        for err_count in range(0, 10):


            try:

                lt= seawater105.count(query)
                pos = list(seawater105.find(query).limit(lt))
                data=pandas.DataFrame(pos)
                del pos
                return data

            except:
                 #err_count = err_count + 1
                 time.sleep(1)
                 print('query error')



        raise Exception("yang ben cha xun shi bai")       
posted @ 2022-08-19 22:59  luoganttcc  阅读(19)  评论(0编辑  收藏  举报