This module converts a relational algebra query into python code, which can be executed using the relational module.

:!: IMPORTANT: It is necessary to use unicode strings instead of normal ones.


import parser


It has 2 class of operators:

Without parameters

Symbol Name Example
* product A * B
- difference A - B
union A ᑌ B
intersection A ᑎ B
ᐅᐊ join A ᐅᐊ B
ᐅLEFTᐊ left outer join A ᐅLEFTᐊ B
ᐅRIGHTᐊ right outer join A ᐅRIGHTᐊ B
ᐅFULLᐊ full outer join A ᐅFULLᐊ B

Syntax for those operators is: relation operator relation

With parameters

Symbol Name Example Note
σ selection σ id==index or rank>3 (A) Expression must be written in python
π projection π name,age (A) Spaces in attributes will be ignored
ρ rename ρ index➡id,age➡old (A) Spaces in the parameters will be ignored

Syntax for those is: operator parameters (relation)

Mixing operators

Since a*b is a relation itself, you can parse π a,b (a*b); and since π a,b (A) is a relation, you can parse π a,b (A) ᑌ B.

You can use parenthesis to change priority: a ᐅᐊ (q ᑌ d)


σage > 25 and rank == weight(A)
Q ᐅᐊ π a,b(A) ᐅᐊ B
ρid➡i,name➡n(A) - π a,b(π a,b(A)) ᑎ σage > 25 or rank = weight(A)
π a,b(π a,b(A))
ρid➡i,name➡n(π a,b(A))
A ᐅᐊ B

expression_converter.txt · Last modified: 2011/12/01 12:15 by LtWorf
Except where otherwise noted, content on this wiki is licensed under the following license: GNU Free Documentation License 1.2
Recent changes RSS feed Valid XHTML 1.0 Valid CSS Driven by DokuWiki