Skip to content

seatable的SQL支持 #140

@Fengzdadi

Description

@Fengzdadi

中文文档里面我没有看到很好的案例,包括这个仓库的案例我也觉得很一般,比如用上GROUP BY等方法,他经常会冒出ConnectionError: [Errno 400] {"error_message":"column "COUNT(*)" must appear in the GROUP BY clause or be used in an aggregate function"},这是完全解决不掉的(至少折腾了我一天),这里的SQL语句(我看仓库的eg做的比较)是不是不能和一般的SQL一样直接写完一段Query,例如

    sql1 = f"""
    SELECT 
      DataPoints.`申请者`      AS applicant,
      COUNT(*)                AS c
    FROM 
      `DataPoints`, `项目列表`
    WHERE 
      DataPoints.`项目`      = `项目列表`.`_id`
      AND `项目列表`.`项目@学校` IN ('{proj1}', '{proj2}')
      AND DataPoints.`结果`   = 'Admit'
    GROUP BY 
      DataPoints.`申请者`
    HAVING 
      c = 2
    """
    rows = base.query(sql1)
    return [r['applicant'] for r in rows]

如果有什么更好的案例,请通知我,谢谢你们

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions