コード例 #1
0
ファイル: test_parser.py プロジェクト: we1l1n/ch2sql
def test_total_04():
    """
    {
    "select": [
        "订单号"
    ],
    "condition_and": [
        "客户名称 = 京东商城"
    ],
    "condition_or": [],
    "order_by_desc": [],
    "group_by": [],
    "having": [],
    "result_limit": null,
    "date_from": null,
    "data_to": null
    }
    """
    from ch2sql.sentence import Sentence
    from ch2sql.database import Table
    from ch2sql.parser import Parser
    import os
    path = "../datasource/销售业绩报表.xlsx"
    assert os.path.exists(path)
    path = os.path.abspath(path)
    table = Table(table_name='销售业绩报表', path=path)
    s1 = "查询京东商城的订单编号"
    s1 = Sentence(s1, table)
    print(s1.nodes)
    s1 = Parser(s1)
    s1.select_parser()
    s1.condition_parser()
    from ch2sql.output import Output
    o = Output(s1)
    print(o.get_json())
コード例 #2
0
ファイル: test_parser.py プロジェクト: we1l1n/ch2sql
def test_total_17():
    from ch2sql.sentence import Sentence
    from ch2sql.database import Table
    from ch2sql.parser import Parser
    import os
    path = "../datasource/销售业绩报表.xlsx"
    assert os.path.exists(path)
    path = os.path.abspath(path)
    table = Table(table_name='销售业绩报表', path=path)
    s1 = "订单编号大于50的客户名称"
    s1 = Sentence(s1, table)
    print(s1.nodes)
    s1 = Parser(s1)
    s1.select_parser()
    s1.condition_parser()
    from ch2sql.output import Output
    o = Output(s1)
    print(o.get_json())
コード例 #3
0
ファイル: test_parser.py プロジェクト: we1l1n/ch2sql
def test_total_08():
    """
     在这种情况下会出现混乱
    :return:
    """
    from ch2sql.sentence import Sentence
    from ch2sql.database import Table
    from ch2sql.parser import Parser
    import os
    path = "../datasource/销售业绩报表.xlsx"
    assert os.path.exists(path)
    path = os.path.abspath(path)
    table = Table(table_name='销售业绩报表', path=path)
    s1 = "各业务员的总订单金额"
    s1 = Sentence(s1, table)
    print(s1.nodes)
    s1 = Parser(s1)
    s1.select_parser()
    s1.condition_parser()
    from ch2sql.output import Output
    o = Output(s1)
    print(o.get_json())
コード例 #4
0
ファイル: test_parser.py プロジェクト: we1l1n/ch2sql
def test_total_20():
    """
    {
    "select": [
        "利润"
    ],
    "condition_and": [
        "客户名称 = 淘宝网"
    ],
    "condition_or": [],
    "order_by_desc": [],
    "group_by": [],
    "having": [],
    "result_limit": null,
    "date_from": "2014-12-01",
    "date_to": "2014-12-31"
     }
    :return:
    """

    s1 = "2014年12月淘宝网的利润"
    from ch2sql.sentence import Sentence
    from ch2sql.database import Table
    from ch2sql.parser import Parser
    import os
    path = "../datasource/销售业绩报表.xlsx"
    assert os.path.exists(path)
    path = os.path.abspath(path)
    table = Table(table_name='销售业绩报表', path=path)
    s1 = Sentence(s1, table)
    print(s1.nodes)
    s1 = Parser(s1)
    print(s1.parser_tree)
    s1.select_parser()
    s1.condition_parser()
    from ch2sql.output import Output
    o = Output(s1)
    print(o.get_json())
コード例 #5
0
ファイル: test_parser.py プロジェクト: we1l1n/ch2sql
def test_total_19():
    """
    {
    "select": [
        "COUNT(订单号)",
        "部门名称"
    ],
    "condition_and": [],
    "condition_or": [],
    "order_by_desc": [],
    "group_by": [
        "部门名称"
    ],
    "having": [],
    "result_limit": null,
    "date_from": "None",
    "date_to": "None"
   }
    :return:
    """
    from ch2sql.sentence import Sentence
    from ch2sql.database import Table
    from ch2sql.parser import Parser
    import os
    path = "../datasource/销售业绩报表.xlsx"
    assert os.path.exists(path)
    path = os.path.abspath(path)
    table = Table(table_name='销售业绩报表', path=path)
    s1 = "各部门名称的订单号总数"
    s1 = Sentence(s1, table)
    print(s1.nodes)
    s1 = Parser(s1)
    print(s1.parser_tree)
    s1.select_parser()
    s1.condition_parser()
    from ch2sql.output import Output
    o = Output(s1)
    print(o.get_json())