代码之家  ›  专栏  ›  技术社区  ›  Sam

getall什么也不返回?重新思考

  •  -1
  • Sam  · 技术社区  · 8 年前

    嗨,我正在尝试从数据库中读取数据库中不同消息的“线程”,但每次尝试时,我都会返回一个空数组,这会导致我在使用 get_all>命令请求所有线程时认为有问题。像这样从数据库请求是正确的吗?根本没有错误,所以我很困惑,因为它应该返回消息的线程。

    def threads(cls,clinic_id,db=):
    “”线程
    
    返回SMS日志中线程的唯一列表
    
    论据:
    诊所ID uint——诊所的唯一ID
    db dict--可选的db信息
    
    返回:
    列表
    “”
    
    #获取信息
    dinfo=cls.info(db)
    
    #连接到服务器
    将connect_与(dinfo['server'])作为ocon:
    
    #请求所有线程
    itres=r\
    .db(dinfo['db'])。\
    .table(dinfo['tree'].名称)\
    .get_all([诊所编号,r.minval],[诊所编号,r.maxval],index=“诊所编号”)。\
    .pull(['数字'])。\
    .默认(无)\
    .distinct()。\
    .运行(OCON)
    
    #返回数字列表
    返回[d['number']以itres表示d]
    
    
    

    .get_all命令。像这样从数据库请求是正确的吗?根本没有错误,所以我很困惑,因为它应该返回消息的线程。

    def threads(cls, clinic_id, db={}):
        """Threads
    
        Returns the unique list of threads in the SMS log
    
        Arguments:
            clinic_id {uint} -- The unique ID of the clinic
            db {dict} -- Optional DB info
    
        Returns:
            list
        """
    
        # Get the info
        dInfo = cls.info(db)
    
        # Connect to the server
        with connect_with(dInfo['server']) as oCon:
    
            # Request all threads
            itRes = r \
                .db(dInfo['db']) \
                .table(dInfo['tree']._name) \
                .get_all([clinic_id, r.minval], [clinic_id, r.maxval], index="clinic_number") \
                .pluck(['number']) \
                .default(None) \
                .distinct() \
                .run(oCon)
    
            # Return the list of numbers
            return [d['number'] for d in itRes]
    

    1 回复  |  直到 8 年前
        1
  •  0
  •   jishi    8 年前

    clinic_id

    .get_all(clinic_id, index="clinic_number")

    .between()

    .filter

    推荐文章