English 中文(简体)
pyparing, Each, results name
原标题:pyparsing, Each, results name

我试图用餐厅建造一个小小块不公的教区(我没有条款,我没有加入任何行列等等)。 我今天的工作以简单的SQL为基础。 典型例子包括假肢。 我试图将“按类别分列的清单”和“按类别分列的清单”条款添加到教区,但试图与这些条款相匹配。

采用每个班级的Im,似乎与他们相配,但并没有从每个班级中确定结果名称。 我要么没有做一些事情,要么正在出现我不清楚的情况。

同样,从简单的SQL来看。 举例来说,我从Token中删除了,因此,我选定的Stmt现在认为:

# define the grammar
selectStmt      << ( selectToken + 
                     columnNameList.setResultsName( columns ) + 
                     Optional( CaselessKeyword( where ) + whereExpression, "" ).setResultsName( where ) + 
                     Each( [ Optional( CaselessKeyword( group by ) + columnNameList, "" ).setResultsName( group ),
                             Optional( CaselessKeyword( order by ) + columnNameList, "" ).setResultsName( order ) ] ) )

我得出以下结果:

SELECT a WHERE a=b  and c = d GROUP BY c, e ORDER By d ->
tokens =  [ select , [ a ],  where , [ a ,  = ,  b ],  and , [ c ,  = ,  d ],  group by , [ c ,  e ],  order by , [ d ]]

SELECT a WHERE a=b and c =d ORDER BY z, y GROUP BY c ->
tokens =  [ select , [ a ],  where , [ a ,  = ,  b ],  and , [ c ,  = ,  d ],  order by , [ z ,  y ],  group by , [ c ]]

因此,它想把集团和秩序条款按顺序排列,但并不分配结果名称(顺序和组)。 我可以看到,这完全是umb,我没有东西,或者我可以看到,我正在以任何命令(以及今后更多的条款,如利比里亚武装部队)找到这些条款。

Any help would be greatly appreciated! LOVING pyparsing so far.

最佳回答

Give this a shot:

Stmt      << ( selectToken +
                columnNameList( columns ) + 
                Optional( CaselessKeyword( where ) + whereExpression( where ), "" ) +
                Each( [ Optional( CaselessKeyword( group by ) + columnNameList( group ), "" ).setDebug(),
                        Optional( CaselessKeyword( order by ) + columnNameList( order ), "" ).setDebug() ] 
                    ) 
            )
问题回答

暂无回答




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签