Skip to content Skip to sidebar Skip to footer

Pyparsing, Each, Results Name

I'm trying to use pyparsing to build a little not-quite-sql parser (I don't have from clauses, I don't have any joins, etc). I've been basing my work today on the simpleSQL.py exam

Solution 1:

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() ] 
                    ) 
            )

Post a Comment for "Pyparsing, Each, Results Name"